Creating Cloud SQL Instance using cloud shell

  • date 30th May, 2021 |
  • by Prwatech |


GCP account

Open the Console.

Click on Activate Cloud Shell.

Paste the below code.

$          export PROJECT_ID=$(gcloud info --format='value(config.project) ')

It will export our project ID into $PROJECT_ID.

$          echo $PROJECT_ID

It will print our project ID

$          export BUCKET=${PROJECT_ID}-ml

It will export the bucket name into $BUCKET

$          echo $BUCKET

It will print the bucket name

$          gcloud sql instances create taxi --tier=db-n1-standard-1

It will create a sql instance with name taxi.

It will take a little bit time to create.

$          gcloud sql users set-password root --host % --instance <sql_instance_name> --password <password>

To set password for SQL instance

$          gcloud sql instances patch <instance-name> --authorized-networks

Press y to continue.

Open Console.

Menu > SQL

Copy the IP address.

$          MYSQL=<IP_ADDRESS>

$          echo $MYSQL

$          mysql --host=$MYSQL --user=root --password

Enter the password which you created. The password will not be visible. Press enter.

Here you can type your mysql codes.

$          show databases

It will list the databases.

$          exit

It will exit from mysql.

Quick Support

image image