6.5.3 How to remotely connect to a database

Banner Remote database connection is an alternative way to work with databases that allows you to use different software instead of the standard phpMyAdmin web interface. With this approach, you can connect to MySQL, PostgreSQL, and other DBMS databases using specialized programs installed on your computer.

Main use cases:

  • Working with databases through convenient graphical editors (MySQL Workbench, DBeaver, HeidiSQL)
  • Direct connection from software applications for development and testing
  • Using advanced administration capabilities not available in phpMyAdmin
  • Automating database operations through scripts and command-line utilities
  • Connecting to databases from local programs for data analysis and visualization

Connection Software

There is a wide selection of software for working with remote databases. Here are some examples of software you can use:

  • MySQL:

    • MySQL Workbench – official tool for working with MySQL.
    • Navicat – tool for working with various DBMS.
    • HeidiSQL – free tool with support for MySQL, PostgreSQL, MSSQL.
    • DBeaver – universal tool for working with various DBMS.
  • PostgreSQL:

    • pgAdmin – popular tool for PostgreSQL administration.
    • Navicat – professional tool for working with various DBMS.
    • DataGrip – integrated development environment from JetBrains.

Setup Process

To work with a database through remote connection, you need to complete three simple steps. First, activate remote access in your database settings. Then install a database management program that best suits your needs on your computer. The final step will be configuring the connection in the program, where you need to specify the database access parameters.

Activating Remote Access

To begin, you need to activate remote access to your database:

  1. Select the desired database, go to the Database Users section.

Database User

  1. Activate remote access for the user and additionally, you can restrict the list of IPs that can connect to the database.

Activating remote access ]

Connection Parameters

You can view the database access parameters in your CMS configuration. Open your site’s configuration file, usually named config.php, configuration.php, or wp-config.php. Alternatively, this could be the graphical interface of your software.

Find the section containing database connection parameters such as server name, database name, username, password, and port.

  • For external connections, use the standard port for MySQL3306 or for PostgreSQL5432.
  • For the host address (server name), specify your hosting server, for example: s#.thehost.com.ua or s#-de.thehost.com.ua.

Important: the host address differs for each service. You can view the current parameters in the access parameters letter.

Connecting with MySQL Workbench

MySQL Workbench is a popular tool for working with MySQL databases. Here’s a step-by-step connection setup guide:

  1. Launch MySQL Workbench.
  2. On the main screen, click + (New Connection) or select Database -> New Connection.
  3. In the connection setup window, specify:
    • Connection Name: arbitrary connection name (for example, MyProject).
    • Connection Method: Standard (TCP/IP).
    • Hostname: your server address.
    • Port: 3306.
    • Username: database username.
    • Password: click Store in Vault and enter the password.
  4. Click Test Connection to verify the connection.
  5. After successful verification, click OK to save the settings.

Connection

Connecting with pgAdmin

pgAdmin is a convenient tool for managing PostgreSQL databases. The connection setup process:

  1. Open pgAdmin.
  2. In the object tree, right-click on Servers and select Register -> Server.

Connection

  1. On the General tab, specify:
    • Name: arbitrary server name for identification (for example, MyProject).

General Tab

  1. Go to the Connection tab and fill in:

    • Host name/address: your server address.
    • Port: 5432.
    • Maintenance database: your database name.
    • Username: database username.
    • Password: access password.
  2. Click Save to save the settings.

Connection

After successful connection, you will see your database in the object tree on the left.

Connection Security:

  • Use strong passwords.
  • Restrict access by IP addresses.
  • Regularly update software.
  • Use SSL/TLS encryption.
  • Configure minimum necessary access rights.