Skip to main content

Connect to a MySQL sync cluster

Last update:

You can connect to a MySQL sync cluster:

  • via the mysql console client;
  • graphical database management tools: phpMyAdmin, MySQL Workbench, Sequel Pro, and others;
  • program code.

For all methods, you can connect with SSL or without SSL.

When connecting, specify the port and address.

The number of connections for a cluster is limited by the amount of RAM.

Connection ports

Use port 6033 to connect to ProxySQL.

ProxySQL automatically distributes requests between cluster nodes.

Connection addresses

The connection address depends on the cluster subnet and where you are connecting from. You can choose an address based on one of the scenarios:

Connecting to a cluster in a public subnet

If a cluster is in a public subnet, you can connect to the nodes using a DNS address or an IP address from the public subnet.

We recommend connecting using a DNS address. DNS addresses use the master discovery mechanism in the cluster—the address is tied to the node role rather than the node itself. If a master becomes unavailable, one of the replicas becomes the new master, and the address moves to the new node along with the role.

The master discovery mechanism is not used when connecting via an IP address from a public subnet. If one of the replicas becomes the new master, the master's IP address will change, and the connection using the old IP address will stop working.

You can view the connection address in the Dashboard.

Connecting from a private subnet to a cluster in a private subnet

If you are connecting from a private subnet to a cluster in a private subnet, you can use a DNS address or a private IP address.

We recommend connecting using a DNS address. DNS addresses use the master discovery mechanism in the cluster—the address is tied to the node role rather than the node itself. If a master becomes unavailable, one of the replicas becomes the new master, and the address moves to the new node along with the role.

The master discovery mechanism is not used when connecting via a private IP address. If one of the replicas becomes the new master, the master's IP address will change, and the connection using the old IP address will stop working.

To connect from another private subnet, first connect both private subnets to a cloud router.

You can view the connection address in the Dashboard.

Connecting from the Internet to a cluster in a private subnet

If you are connecting to a cluster in a private subnet from the Internet, you can only use a public IP address (Floating IP). The private subnet must meet the requirements. If the subnet does not meet the requirements, prepare it for a public IP address (Floating IP).

Public IP addresses (Floating IPs) use the master discovery mechanism—the address is tied to the node role rather than the node itself. If a master becomes unavailable, one of the replicas becomes the new master, and the address moves to the new node along with the role.

You can view the connection address in the Dashboard.

View the connection address

  1. In the Dashboard, in the top menu click Products and select Managed Databases.
  2. Open the Active tab.
  3. Open the database cluster page → Connection tab.
  4. In the Connection addresses block, view the address.

Number of connections

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

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

Connect via SSL

Connecting using TLS (SSL) encryption ensures 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=<port> \
    --user=<database_user_name> \
    --password \
    --database=<database_name> \
    --ssl-ca=~/.mysql/root.crt \
    --ssl-mode=verify_ca

    Specify:

    • <host> — the DNS address or public IP address (Floating IP) of the node;
    • <port>connection port;
    • <database_user_name> — database user name;
    • <database_name> — database name.

Connect without SSL

  1. Open the CLI.

  2. Connect to the cluster:

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

    Specify:

    • <host> — the DNS address or public IP address (Floating IP) of the node;
    • <port>connection port;
    • <database_user_name> — database user name;
    • <database_name> — database name.

Connect via phpMyAdmin

Add the following 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'] = '<port>';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

Specify: