How to export database from Google CloudSQL?
To export a database from Google Cloud SQL, you can use the gcloud command-line tool. Here are the steps:
- Connect to your Cloud SQL instance using the gcloud tool:
gcloud sql connect [INSTANCE_NAME] --user=[USERNAME]
- Run the mysqldump command to export the database:
mysqldump -u [USERNAME] -p [DATABASE_NAME] > [EXPORT_FILE_NAME].sql
- Enter the password when prompted.
- Wait until the export is completed, and then you will have a file with the name you provided in [EXPORT_FILE_NAME].sql
- To import the data again you can use mysql command :
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.
To export a database from Google Cloud SQL using the Google Cloud Console, you can follow these steps:
- In the Cloud Console, go to the Cloud SQL instances page.
- Select the instance that contains the database you want to export.
- Click on the “Export” button in the top-right corner of the page.
- Select the database you want to export and choose a location to save the export file.
- Click on the “Export” button to start the export process.
- Wait for the export to complete. A message will appear in the Cloud Console when the export is done.
- 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.