virtualMachinejoomla

Connect to MariaDB from a different machine

NOTE: We are in the process of modifying the configuration for many Bitnami stacks. On account of these changes, the file paths and commands stated in this guide may change depending on whether your Bitnami stack uses MySQL or MariaDB. To identify which database server is used in your stack, run the command below:

 $ test -d /opt/bitnami/mariadb && echo "MariaDB" || echo "MySQL"

The output of the command indicates which database server (MySQL or MariaDB) is used by the installation, and will allow you to identify which guides to follow in our documentation for common database-related operations.

IMPORTANT: Making this application’s network ports public is a significant security risk. You are strongly advised to only allow access to those ports from trusted networks. If, for development purposes, you need to access from outside of a trusted network, please do not allow access to those ports via a public IP address. Instead, use a secure channel such as a VPN or an SSH tunnel. Follow these instructions to remotely connect safely and reliably.

To connect to your database server remotely using the MariaDB client, follow these steps:

NOTE: Ensure that your virtual machine has a local network IP address. To configure your virtual machine to connect to your local network, refer to these instructions. Once connected, you can obtain the IP address of your virtual machine at any time by running the command ifconfig -a in the virtual machine server console.

  • Log in to your virtual machine console.

  • Open port 3306 in the server firewall (instructions).

  • Edit the MariaDB configuration file and find the line containing:

      bind-address=127.0.0.1
    
  • Comment out this line by placing a hash (#) symbol at the beginning, so that it looks like this:

      #bind-address=127.0.0.1
    
  • Save the file.

  • At the server console, allow remote access to the database server using the command line client. Use the following command, remembering to replace PASSWORD with the application password from the first step:

      $ /opt/bitnami/mariadb/bin/mariadb -u root -p -e "grant all privileges on *.* to 'root'@'%' identified by 'PASSWORD' with grant option";
    
  • When prompted for a password, enter the default password bitnami. In case you have changed the default password, enter the new password.

  • Restart the server:

      $ sudo /opt/bitnami/ctlscript.sh restart mariadb
    
Last modification December 21, 2022