nativeInstallermoodle

Connect to MySQL/MariaDB from a different machine

Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and Mac OS X) or by clicking the shortcut in the Start Menu under “Start -> Bitnami APPNAME Stack -> Application console” (Windows). Learn more.

IMPORTANT: Bitnami Native Installers do not modify the firewall configuration of your computer, therefore the Moodle ports could be open which is a significant security risk. You are strongly advised to close the Moodle ports (refer to the FAQ for more information on this).

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

Windows, Mac OS X, Linux

  • Open port 3306 in your firewall. For example, if you are using ufw, you would run the following commands (on Linux only):

    $ sudo ufw allow mysql/tcp
    
  • At the server console, edit the file installdir/mysql/my.cnf 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:

    $ installdir/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 password you entered during the installation process.

  • Restart the database server using the graphical manager (Windows and Mac OS X) or by executing the following command at the server console (Linux):

    $ sudo installdir/ctlscript.sh restart mysql
    

    MySQL manager

You can then connect to the database server using a command like the one below.

$ mysql -h 127.0.0.1 -P 3306 -u root -p

You will be prompted to enter the root user password. This is the same as the application password.

Mac OS X-VM

  • Select the “Network” tab, then click “Add”.

    MySQL Workbench configuration for Mac OS X-VM

  • On the resulting dialog, enter 3306 as local and remote port. Active the “Require local” and “Over SSH” checkboxes, and click “Ok” to save your changes.

    MySQL Workbench configuration for Mac OS X-VM

  • On the “Network” section, you will see an SSH tunnel to the 3306 port enabled.

    MySQL Workbench configuration for Mac OS X-VM

  • If the connection is successful, click “OK” to save the connection.

    MySQL Workbench configuration

You can then connect to the database server using a command like the one below.

$ mysql -h 127.0.0.1 -P 3306 -u root -p

You will be prompted to enter the root user password. This is the same as the application password.