Importing a database

Apart from the databases we create on Cloud SQL instances, we can also import other databases from other sources (otherwise nobody would ever switch to Cloud SQL in the first place!):

  1. We can download one of the sample databases from the official MySQL website using the wget command:
wget https://codeload.github.com/datacharmer/test_db/zip/master -O sampledb.zip 
  1. After downloading you will have a sampledb.zip file. Unzip it. This will create a test-db-master directory in your current working directory.
  2. Navigate there using the cd command and find employees.sql using the ls command.
  3. After examining this file you will find that it contains a number of SQL statements to drop existing databases and recreate the database and tables within them.
  4. Using the gcloud command line you can connect your SQL instance and run all the commands that are present in the employees.sql file. This will create an employees database and create all the tables mentioned in it:
gcloud beta sql connect bank-balance --user=root< employees.sql  

Now we have two databases; Accounts and Employees. Before making a shift from our dominant RDBMS to Cloud SQL, we also need to test whether it delivers what it promises!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset