Connecting to MySQL

Grab your Credentials and Connection String to connect to your MySQL deployment in the ScaleGrid DBaaS.

Once you've created a new MySQL deployment through the ScaleGrid console, you can easily connect to it using either a MySQL client or through your application.


Network Connectivity

Skip to the next step if you've already configured your network settings.

Ensure that your network settings allow the client machine to connect to port 3306 on instances of the MySQL deployment by setting up the following:

  • If your deployment is open to the Internet, ensure that your client is whitelisted either under the Cluster Firewall Settings or under the Account Firewall Settings on the ScaleGrid console. Whether your deployment is open to the Internet or not depends on the Cloud Profile settings.
  • If you cluster is NOT open to the Internet, then the network settings need to be determined from the VPC and Security Group settings of the cloud provider themselves. Refer to the documentation of your cloud provider to find out the correct configuration required to ensure connectivity.

MySQL User

In order to connect to your MySQL deployment, you must first create a new user, as it is highly recommended that you do not use the sgroot user that was created with your cluster. Follow these steps to create a new user for your MySQL deployment:

Connecting To Your MySQL Database

Connection Endpoints

Before connecting to your MySQL database, you can select the endpoint your application needs to connect to. In a replica-set deployment, you will have the following endpoints defined.

  • Master - This endpoint always points to the Master (or source) of your MySQL deployment.
  • Read Replica (Generic) - Points to 1 or more replica nodes depending on the number of replica nodes configured in your deployment. For example, in a 3-node deployment with 2 replicas, Read Replica (Generic) endpoint will be a DNS A record containing the IP addresses of the 2 replica nodes. When this endpoint is used from your application, the traffic will be automatically distributed between the 2 replicas.
  • Read Replica - Each read replica in your deployment will get its own endpoint. Typically endpoints can be used in your applications that do specific jobs like like Reporting, Analytics etc.
  • For High Performance MySQL deployments, that use a local ssd node for the data, there will be special endpoints labelled as Read Replica SSD , that always point to SSD replica nodes.

** Please note that any replica endpoint above, should be strictly used for read-only traffic.

There are various ways to connect to your MySQL database, and you can choose from the following methods below:

Debugging Connection Problems in MySQL

  • Can't connect to MySQL server on
    Ensure that your client IP is white-listed in the Firewall rules configuration through ScaleGrid console. Please note that if you have created any account level firewall rules, they still need to be applied for your deployment from the Firewall Rules button in the Overview page of your deployment as shown below.

Click Configure to apply the Account level firewall

  • ‘Access Denied’ for user [email protected](using password: YES) occurred while trying to connect to host:

This will be typically a username and password issue. Ensure that the MySQL user you have created has access to connect to MySQL server from external clients. The host component of the username should be either % OR IP address of the client from where you are trying to connect. Valid user names are user1@% , [email protected] etc.