With gcloud command-line tool

To export a database from Google Cloud SQL, you can use the gcloud command-line tool. Here are the steps:

  1. Connect to your Cloud SQL instance using the gcloud tool:
1
gcloud sql connect [INSTANCE_NAME] --user=[USERNAME]
  1. Run the mysqldump command to export the database:
1
mysqldump -u [USERNAME] -p [DATABASE_NAME] > [EXPORT_FILE_NAME].sql
  1. Enter the password when prompted.
  2. Wait until the export is completed, and then you will have a file with the name you provided in [EXPORT_FILE_NAME].sql
  3. To import the data again you can use mysql command :
1
mysql -u [USERNAME] -p [DATABASE_NAME] < [EXPORT_FILE_NAME].sql

Note: Replace [INSTANCE_NAME], [USERNAME], [DATABASE_NAME], and [EXPORT_FILE_NAME] with the appropriate values for your Cloud SQL instance.

With Google Cloud Console

To export a database from Google Cloud SQL using the Google Cloud Console, you can follow these steps:

  1. In the Cloud Console, go to the Cloud SQL instances page.
  2. Select the instance that contains the database you want to export.
  3. Click on the “Export” button in the top-right corner of the page.
  4. Select the database you want to export and choose a location to save the export file.
  5. Click on the “Export” button to start the export process.
  6. Wait for the export to complete. A message will appear in the Cloud Console when the export is done.
  7. To import the data again you can use the “Import” button, in the same location as the export button.

Please note that the export file will be in SQL format and can be imported in any MySQL compatible database.