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

Connect to MySQL semi-sync cluster

The MySQL semi-sync cloud database cluster can be connected to by DNS address, private IP address, and public IP address.

We recommend connecting by DNS address because DNS addresses correspond to 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 the cluster subnet to a cloud router with access to the external network. Use the following instructions Set up internet access via cloud router.

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

Ports

Use port 3306 to connect to the cluster.

Ways of connection

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

Connection with SSL certificate is available for all methods.

View the address for connection

  1. В control panels go to Cloud platformDatabases.
  2. Open the Database Cluster page → tab Connection.
  3. In the block Addresses for connection check out the address.

Number of connections

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

To increase the number of connections, scale the cluster to the right 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 folder ~/.mysql/:

    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=3306 \
    --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> — database user name;
    • <database_name> — database name.

Connect without SSL

  1. Open the CLI.

  2. Connect to the cluster:

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

    Specify:

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

Connect via phpMyAdmin

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

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

Specify <host> — DNS address of the node.