MySQL Connection

How to add MySQL database connection on Windows

  1. Open SqlBak app and click “+Add” button to add new server connection.
  2. In the pop-up window, choose “MySQL” in the DBMS type dropdown.
  3. Enter the Host name and Port.
  4. Select the authorization method:
    • Username & Password: enter the MySQL username and password for the specified account.

    • Login-Path: enter the name of the predefined MySQL Login Path, created using the mysql_config_editor tool.

  5. (Optional) Click Advanced Settings to configure:

    • Path to bin folder. SqlBak detects the path to the MySQL bin folder automatically, so this setting is usually not required.
      However, if you encounter version compatibility issues, you can specify the path manually.
      Example: 📂C:\Program Files\MySQL\MySQL Workbench 8.0
    • Connect timeout. The time (in seconds) to wait for a connection to open.
      This option defines how long SqlBak will wait when trying to establish a connection to the MySQL server before timing out. If your server is under heavy load or on a slow network, you may want to increase this value.

    • Command timeout. The time (in seconds) to wait for a command to execute.

      This setting controls how long SqlBak will wait for a SQL command to complete. If you’re working with large databases or slow operations, increasing this value can help prevent timeouts.

       

      SqlBak MySQL server connection advanced settings
    • Connect using SSH tunnel

      This option allows you to securely connect to a remote MySQL server that is not directly accessible over the network. Instead of connecting to the MySQL port directly, SqlBak will establish a secure SSH tunnel, and forward the MySQL connection through it.

      This is useful in scenarios such as:

      • The MySQL server is behind a firewall or NAT and only accessible via SSH.

      • You want to encrypt traffic between SqlBak and the database server without enabling SSL on MySQL.

      • Your security policy restricts direct MySQL access and requires using SSH.

      To configure SSH tunneling, fill in the following fields:

        • SSH host – the hostname or IP address of the SSH server that has access to the MySQL instance. Example: ssh.mycompany.com or 192.168.1.100

        • SSH port – The port on which the SSH server is listening. Default is 22, unless changed in your server’s configuration.

        • Locally mapped port – This is the local port on your machine that will be used to forward the MySQL connection through the SSH tunnel. Example: If you set 3307, then SqlBak will connect to localhost:3307 internally, which will be securely forwarded to the remote MySQL server.

          ⚠️ Make sure the selected port is not already in use on your machine.

        • SSH username – The username used to authenticate on the SSH server. This must be a valid user account with SSH access to the remote server.

        • Authentication method – Choose how to authenticate with the SSH server:

          • Password – Enter the SSH user’s password.

          • Private/Public key – Upload or specify a path to the SSH private key file (e.g., id_rsa) used for key-based authentication. Ensure that the key file permissions and format are valid.

             

            SqlBak MySQL server connection via SSH

6. Click “Test Connection” to verify access and “Save & Close” to save connection.

How to add a MySQL database connection on Linux

1. Open the terminal and run the following command:

sqlbak

2. In the interactive menu, select: 1. Manage backup source connections → 1. Add a backup source connection

Enter 2 to add a MySQL connection.

3. Enter MySQL connection parameters:

    • Connect using SSH tunnel:

      • Enter Y to configure an SSH tunnel if your MySQL server is only accessible via SSH.
      • Enter N for a direct connection. (default)
    • MySQL Server name: Enter the server name or IP address (default: localhost)

    • MySQL port: Enter the port number (default: 3306)

    • MySQL user name: Enter the MySQL username (default: root)

    • MySQL user password: Enter the password (hidden input)

Advanced settings

  • Path to mysql bin folder: SqlBak detects the path to the MySQL bin folder automatically, so this setting is usually not required (leave empty). 
    However, if you encounter version compatibility issues, you can specify the path manually.
    Example: 📂C:\Program Files\MySQL\MySQL Workbench 8.0
  • Connection timeout (sec):
    Time in seconds to wait for the connection to establish. Default: 15
  • Command timeout (sec):
    Time in seconds to wait for MySQL commands to complete. Default: 30

 

MySQL database connection on Linux

Non-interactive CLI setup

For Docker containers, scripts, and automated server setup, you can configure a MySQL source without using the interactive menu.

First, create a default MySQL source settings file:

sqlbak source get-default --source-type=mysql --save-to-file=/tmp/mysql-source.json --confirm

Open /tmp/mysql-source.json in a text editor and fill in the MySQL connection details.

Before saving the source, test the connection:

sqlbak source test-connection --source-type=mysql --load-from-file=/tmp/mysql-source.json

If the test succeeds, add the source:

sqlbak source add --source-type=mysql --load-from-file=/tmp/mysql-source.json

You can list configured sources with:

sqlbak source list

Docker note

When SqlBak runs in Docker, the MySQL host name must be reachable from inside the SqlBak container. If MySQL is another service in the same Docker Compose file, use the service name as the host. Do not use localhost for a database running in another container.