Skip to main content
Connect to MySQL sync cluster
Last update:

Connect to MySQL sync cluster

You can connect to the MySQL sync cloud database cluster by DNS address, private IP address, and public IP address.

We recommend connecting by DNS address because the DNS addresses correspond to the node roles and lead to the actual IP addresses of the master and replicas. IP addresses correspond to specific nodes. If the master is unavailable, one of the replicas will assume its role, the master's IP address will change, and the IP connection will stop working.

If the cluster is connected to a private subnet and you want to work with it via DNS, connect cloud router-to-external-network to the cluster subnet.

If the cluster is connected to a private network and you need to configure access to the node from the Internet, connect public IP address.

Ports

Use port 6033 to connect to ProxySQL.

ProxySQL automatically distributes queries among the nodes in the cluster.

Ways to connect

  • through the mysql terminal client;
  • through graphical tools for database management: phpMyAdmin, MySQL Workbench, Sequel Pro and others;
  • from the with SSL and without SSL program code.

Connection with SSL certificate is available for all methods.

View the address to connect

  1. In Control Panel, go to Cloud PlatformDatabases.
  2. Open the Database Cluster page → Connect tab.
  3. In the Addresses to connect block, look up the address.

Number of connections

The number of connections for the MySQL sync cluster is determined by the amount of RAM for the database cluster nodes. For every 1 GB of RAM, 50 connections are available. For example, for a cluster with 4 GB RAM, 200 connections are available; for a cluster with 6 GB RAM, 300 connections are available.

To increase the number of connections, scale the cluster to the desired amount of RAM.

Connect with SSL

Connecting using TLS/SSL encryption provides a secure connection between your server and the database cluster.

  1. Download the root certificate and place it in the ~/.mysql/ folder:

    mkdir -p ~/.mysql/
    wget https://storage.dbaas.selcloud.ru/CA.pem -O ~/.mysql/root.crt
    chmod 0600 ~/.mysql/root.crt
  2. Connect to the cluster:

    mysql --host=<host> \
    --port=6033 \
    --user=<database_user_name> \
    --password \
    --database=<database_name> \
    --ssl-ca=~/.mysql/root.crt \
    --ssl-mode=verify_ca

    Specify:

    • <host> — DNS address of the node;
    • <database_user_name> is the database username;
    • <database_name> is the name of the database.

Connect without SSL

  1. Open the CLI.

  2. Connect to the cluster:

    mysql --host=<host> \
    --port=6033 \
    --user=<database_user_name> \
    --password \
    --database=<database_name>\

    Specify:

    • <host> — DNS address of the node;
    • <database_user_name> is the database username;
    • <database_name> is the name of the database.

Connect via phpMyAdmin

Add lines to the /etc/phpmyadmin/config.inc.php configuration file:

$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['host'] = '<host>';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['port'] = '6033';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

Specify <host> — the DNS address of the node.