MySQL Database migration to Google Cloud SQL

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.

Image for post
Image for post

The steps to migrate MySQL database to Google Cloud SQL are:

  1. Create a dump file from your MySQL server.
  2. Log IN to your GCP Console.
  3. Make a project.
  4. Create a Google Cloud Storage bucket.
  5. Copy the dump file in the GCP bucket.
  6. Create a Cloud SQL for SQL Server instance.
  7. 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:

2. Open Cloud Shell and Create a Google Cloud Storage bucket: You can create a Google Cloud Storage bucket using the following command

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

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

  1. From the GCP console go to Cloud SQL.
  2. Click on the SQL instance name then click on the Database tab.
  3. Create Database.
  4. Enter the database name then click on Create.
  5. Navigate to the overview tab and click on import.
  6. In source field, browse the sql dump file from cloud storage bucket which we have created already.
  7. Select format of file as SQL.
  8. In the destination field, select the database name which you created just now.
  9. 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:

Linkedin: https://www.linkedin.com/in/mayank-chourasia-38421a134/

Twitter: https://twitter.com/ChourasiaMayank.

Google Cloud Google Developers MySQL Avocado @GoogleCloudSQL

Written by

I am Google Cloud Certified Associate Cloud Engineer and MS Azure Certifed. I have been working on different fields including Data Science, DevOps and Anthos.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store