Skip to main content

Remote database servers

Introduction

FASTPANEL® allows to connect external database servers: MySQL or PostgreSQL; thus giving an opportunity to work with databases located on external servers.

important

External databases cannot be added into backup plans, and settings management is not available for external database servers in FASTPANEL®

This article describes an example of connecting an external DBMS server to the FASTPANEL® on the main server.

note

Examples in this article use nominal IP 1.1.1.1 as the address of the main server with FASTPANEL® . Real external server address doesn’t matter, but outside of the examples given in this article it has nothing to do with 1.1.1.1

MySQL database server connection

To connect an external MySQL server to FASTPANEL® follow the steps:

  1. By executing the following query you will create an external MySQL server user who is granted privileges to allow external connections and databases management. To perform it, you must log in mysql as an administrative user:

    CREATE USER 'FASTPANEL_USER'@'FASTPANEL_IP' IDENTIFIED BY 'PASSWORD';
    • FASTPANEL_USER - the user name which will be used for FASTPANEL® connections to the server
    • FASTPANEL_IP - an IP address of the server with FASTPANEL® installed
    • PASSWORD - the password which will be used for FASTPANEL® connections to the server

    Query example:

    MySQL query example to create a remote user in FASTPANEL

  2. Grant administrative privileges for the created user by executing the following query

    GRANT ALL PRIVILEGES ON *.* TO FASTPANEL_USER@'FASTPANEL_IP' WITH GRANT OPTION;
    • FASTPANEL_USER - the user name which will be used for FASTPANEL® connections to the server.
    • FASTPANEL_IP - is the IP address of the server with FASTPANEL® installed

    Query example:

    MySQL query example to grant privileges to remote user in FASTPANEL

  3. Make MySQL listen to all network interfaces. This requires editing or adding the following line into MySQL configuration file (most frequently it is /etc/mysql/my.cnf but may vary):

    bind_address = *

    To enable new settings MySQL requires restarting. For systemd-type systems it can be achieved by executing the following command:

    systemctl restart mysql

To finish setup perform the following actions in the FASTPANEL® on the main server

  1. Go to "Settings" → "Databases"

    Databases management menu in FASTPANEL

  2. Click "Database servers"

    Database servers menu in FASTPANEL

  3. Click "Add a server" button, then uncheck "Local server" checkbox and fill in the fields with the data to connect the external server from the previous steps

    Add a database server in FASTPANEL Add MySQL server in FASTPANEL

If everything is done correctly, a new line with an added server information will appear in the "Database servers" page. After that this server will become available for database creating.

PostgreSQL database server connection

To connect an external PostgreSQL server to FASTPANEL® follow the steps:

  1. By executing the following query you will create an external PostgreSQL server user who is granted privileges to allow external connections and databases management. To perform it, you must log in psql as an administrative user:

    CREATE USER FASTPANEL_USER WITH ENCRYPTED PASSWORD 'USERPASSWORD' SUPERUSER BYPASSRLS REPLICATION CREATEDB CREATEROLE INHERIT LOGIN;
    • FASTPANEL_USER - the user name which will be used for FASTPANEL® connections to the server
    • USERPASSWORD - the password which will be used for FASTPANEL® connections to the server

    Query example:

    PostgreSQL query example to create a remote user in FASTPANEL

  2. Grant the created user external connections privileges by adding the following lines into postgresql config file pg_hba.conf

    host all FASTPANEL_USER 0.0.0.0/0 md5
    host all FASTPANEL_USER ::/0 md5

    File Example:

    PostgreSQL privileges configuration example

  3. Make PostgreSQL listen to all network interfaces. This requires adding the following line into PostgreSQL configuration file (most frequently it is /etc/postgresql/VERSION/main/postgresql.conf):

    listen_addresses = '*'

    PostgreSQL requires restarting to enable settings. In systemd-type systems it can be done by executing the following command:

    systemctl restart postgresql

To finish the setup, perform the following actions in FASTPANEL® on the main server:

  1. Go to "Settings" → "Databases"

    Databases management menu in FASTPANEL

  2. Click "Database servers"

    Database servers menu in FASTPANEL

  3. Click "Add a server" button

    Add a database server in FASTPANEL

  4. Uncheck "Local server" checkbox and fill in the fields with the data to connect the remote server from the previous steps

    Add PostgreSQL server in FASTPANEL

If everything is done correctly, a new line with an added server information will appear in the "Database servers" page. After that this server will become available for database creating.