Connect to MySQL

Please note: We recommend connecting to Chartio through our primary setup mechanism, the reverse SSH tunnel. Instructions on doing that can be found here.

Important Note: If you are concerned about security, we recommend that you use the SSL Secure connection instructions available here to ensure that your summary data is completely encrypted at all points.

If you are familiar with database connections and have used remote tools such as Sequel Pro, MySQL Administrator, or MySQL Query Browser, then you can simply complete step 1 below (creating a read only chart.io user) and go straight to the connection form which should look very familiar. Otherwise, follow the steps below.

Requirements

  • MySQL database running on an accessible server.
  • A MySQL login with permission to create new MySQL users. (recommended)
  • Your security groups are adjusted to account for us accessing your system from the following IP: 173.203.98.78

Steps

First: Create a Chartio read only user.

The first step is to create a unique user (someusername) and password (somepassword) with read only access from chart.io domains only. Simply log into your MySQL interface and paste the following command with the name of yourdatabase and your choices for someusername and somepassword.

    mysql> GRANT SELECT ON yourdatabase.* TO someusername@’chart.io’ IDENTIFIED BY “somepassword“;
    mysql> FLUSH PRIVILEGES;

This step ensures that none of your team members can damage the database with malformed queries, and that the username and password credentials can only be accessed directly from chart.io servers.

Second: Ensure an open port.

If your application and database is being accessed from more than one server, it is probably already available on an open port (default of 3306). If you are not sure of the port number or whether it is open you need to open MySQL’s configuration file (my.cnf). On Debian machines it would be located at /etc/mysql/my.cnf.

    $ nano /etc/mysql/my.cnf

There are two lines to check. ”port” which should be under the [client] heading tells you which port mysql is accessible on. By default it will be port 3306, but you can change it to any alternative open port if you’d like.

    [client]
    port = 3306

The second line to check for is “bind-address” which by default is uncommented but needs to be commented out for servers other than the localhost to access the database.

    #bind-address = 127.0.0.1

If you found you had to make any edits you are now set to restart your server which will then be open for connections on the port you listed. On Debian machines restarting MySQL is done with the following command

    $ /etc/init.d/mysql restart

EC2 Users: If your database is deployed on EC2 you may have one additional step as EC2 has an extra layer of port security. You need to log into your AWS Management Console and ensure that the security groups of the server to allow access on your chosen port.

Third: Chartio form

You can now simply go to your chart.io project settings and add a data source filling in the fields from the values we created above.

If there are any connection issues chart.io should display the proper MySQL error which will help you discover what went wrong with your configuration.

Get stuck?

If you have any trouble with connecting please do not hesitate to contact us at contact@chart.io.