This article will help us learn How to use the "Cloud SQL" service to host a database server within the Google Cloud environment. Google Cloud SQL is a fully-managed database service. It is easy to set up, maintain, manage and administer your relational MySQL, PostgreSQL, and SQL Server databases in the cloud and no prior installation knowledge is required. We can use Cloud SQL for WordPress sites, e-commerce applications, Content Management systems, enterprise solutions, or any other application which requires a relational database to store data. It is easy to use, and it automates all your backups, replication, patches, and updates - while ensuring greater than 99.95% availability anywhere in the world. In addition, Cloud SQL is SSAE 16, ISO 27001, PCI DSS v3.0, and HIPAA compliant, and it helps your data encryption.
The essential point we will cover in this article,
- Launch a new Cloud SQL environment.
- Enable access for specific IP addresses.
- Test Cloud SQL connectivity.
- Execute SQL queries.
To use Cloud SQL, we need first to launch its services. We assume you already have a Google Cloud account, and billing is enabled. Without a valid billing account, you cannot continue to the next step. We have a valid Google Cloud account, and billing is enabled. To start first, we need to open Dashboard by visiting the following URL.
https://vlgo.in/gclouddash or https://console.cloud.google.com/home/dashboard

Next, we need to open the "Marketplace" from the left menu. At the "Marketplace," we will search for the "Cloud SQL" and select it.

On the "Cloud SQL" page, we have all the "Cloud SQL" related information. Then, we will click on the "GO TO CLOUD SQL" button for the article. It will open the "Cloud SQL" instance page. Here we can create a new instance or access the existing instance.


First, we need to click on the "Create Instance" button to create a new instance. After that, we need to select the "Database Engine" type. Next, we needed to deploy a Microsoft SQL Server cloud database server, so we clicked on the "Choose SQL Server" button to open the "Create a SQL Server Instance" page.

Here we need to provide the new instance-related information. Following the information we need to provide, click on the "CREATE INSTANCE" button.
Instance Id: It is your instance id. It must be a unique lower case string that only includes letters, numbers, and hyphens.
Password: You need to enter the password for the SQL Server administration account "sqlserver."
Database Version: Select the appropriate Microsoft SQL Server version.
Zone availability: We are using a "Single zone." You may select the "Multizone" for High Availability.
Customize your instance
Machine type: 1 vCPU, 3.75 GB
Storage
Storage type: SSD
Storage capacity: Custom 10 GB
Backup: Disabled automatic backup.

Once you select the appropriate property value, click on the "CREATE INSTANCE" button. Then, wait for the instance to run. Once the instance is ready, we will get the server IP. We can use the SQL Server Management Studio or another database IDE to check the server connection. We need the server IP address and password we set for the user "sqlserver" in the steps above to connect.



As shown in the above image, the server connection is not successful. Therefore, to allow any specific IP to connect with the server, we must add it to the allow list. To add an IP in the allow list, we need to click on the "Connections" and click on the "ADD NETWORK" button. After that, we need to provide the name and IP address. Finally, click on the "Done" button. It will save all the changes.

After saving the new IP address, try connecting to the database server one more time. Now, we can connect with SQL Server using the allowed IPs. Finally, we will create a test database using the following SQL command.
CREATE DATABASE TestDatabase
GOOur Microsoft SQL Server Google Cloud SQL service is up and running. You can refer to the following article to create a MySQL server service with Google Cloud SQL.

