Hello Everyone, Hope you are well..!!
In this guide, we learn how to migrate the MySQL database to Google Cloud SQL, this means you will be able to host a MySQL database in Cloud SQL, and access it from ‘just about any application, running anywhere’’..
Google Cloud SQL is a fully-managed database service that makes it easy to set-up, maintain, manage, and administer your relational MySQL databases in the cloud.
The steps to migrate MySQL database to Google Cloud SQL are:
- Create a dump file from your MySQL server.
- Log IN to your GCP Console.
- Make a project.
- Create a Google Cloud Storage bucket.
- Copy the dump file in the GCP bucket.
- Create a Cloud SQL for SQL Server instance.
- Import the database into Cloud SQL for SQL Server from GCP bucket.
1.Create a dump file from your MySQL server: Login to the MySQL server, use mysqldump to export the MySQL database to a dump file with the following flags:
mysqldump — databases database_name-h localhost -u blogadmin -p — hex-blob — skip-triggers — single-transaction — default-character-set=utf8mb4 > database_name.sql
2. Open Cloud Shell and Create a Google Cloud Storage bucket: You can create a Google Cloud Storage bucket using the following command
gsutil mb gs://[bucket-name]
Note:bucket-name refers to a Unique Name we have to give.
3. Copy the dump file in the GCP bucket: You can copy the dump file into the Google Cloud Storage bucket using this command
gsutil cp ~/database_name.sql gs://[bucket-name]
4. Create a Cloud SQL for SQL Server instance: In the GCP console, navigate to SQL and click Create instance. Click on MySQL and give any name to the SQL instance, e.g. demo. Generate a root password and then click Create.
5.Import the database into Cloud SQL for SQL Server from GCP bucket
- From the GCP console go to Cloud SQL.
- Click on the SQL instance name then click on the Database tab.
- Create Database.
- Enter the database name then click on Create.
- Navigate to the overview tab and click on import.
- In source field, browse the sql dump file from cloud storage bucket which we have created already.
- Select format of file as SQL.
- In the destination field, select the database name which you created just now.
- Click on Import to start the process.
For any Query you can reach Me from the following Medium.
Stay tuned till the next blog
If you Want to Connect with Me: