Connect To MySQL From Your Application
At ScaleGrid, we make it easy to connect your fully managed MySQL hosting deployment from your application using your Connection String. MySQL deployments at ScaleGrid are available with and without SSL enabled, and you can connect to them in either case. Follow these steps to connect to your deployment from your app:
- Login to the ScaleGrid console.
- Go to your MySQL Cluster Details page.
- Find your Connection Strings on the Overview tab, and click on the See More link for the full list of programming interfaces and languages to connect through:
JDBC
ODBC
PHP
Python
Ruby
Node.js
Example: Connecting to SSL enabled MySQL deployment using JDBC
1: Obtain your JDBC connection string as explained in the above section. Let's say your connection string is is:
jdbc:mysql://SG-prod5725-908-master.servers.mongodirector.com:3306/<your-database-name>?useSSL=true&verifyServerCertificate=true
2: Download and save the ssl ca certificate as explained in the section
3: You will now need to add the ca certificate to java trusted keystore
On Linux based system execute the command:
keytool -import -alias "MySQLCert" -file <path to your ca.pem>
-keystore "/usr/java/default/jre/lib/security/cacerts" -noprompt -storepass "changeit"
On Windows system execute the command in the administrator mode:
<path to the jdk>/bin/keytool.exe -import -alias 'MySQLCert' -file <path of ca.pem file> -keystore "<path to the jdk>\jre\lib\security\cacerts" -noprompt -storepass "changeit"
You will now be all set to connect to your ssl enabled MySQL deployment using JDBC
JDBC connection without CA cert verification
You can turn off the SSL CA cert validation in your JDBC connection string as below. In such a case you do not need to download the ca certificate and add it to the trusted keystore
jdbc:mysql://SG-prod5725-908-master.servers.mongodirector.com:3306/<your-database-name>?useSSL=true&verifyServerCertificate=false
Updated over 1 year ago