Connect to MySQL/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 MySQL 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). For example:
$ sudo ufw allow mysql/tcp
Edit the MySQL configuration file and find the line containing:
Comment out this line by placing a hash (#) symbol at the beginning, so that it looks like this:
Save the file.
At the server console, allow remote access to the database server using the MySQL command line client. Use the following command, remembering to replace PASSWORD with the application password from the first step:
$ /opt/bitnami/mysql/bin/mysql -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 mysql