How to access MariaDB remotely?

We do not recommend creating an external shortcut to the database for security. But if you know what you’re doing, you’ll know your own risks.

In order to remotely access MySQL (MariaDB) in VitalPBX you must follow the following steps.

  1. Make sure that port 3306 is not blocked in your firewall
  2. Create the Service in the VitalPBX Firewall (Admin/Firewall/Services) with port 3306
  3. Create the Rule (Admin/Firewall/Rules) to use the previously created Service.
  4. Go to your server console and modify the 50-server.cnf file.
nano /etc/mysql/mariadb.conf.d/50-server.cnf

Change:

bind-address = 127.0.0.1

to

bind-address = 0.0.0.0

Finally, restart MariaDB.

sudo systemctl restart mariadb
  1. And last but not least, configure the DB credentials to access remotely.
mysql -uroot
MariaDB [(none)]>  GRANT ALL PRIVILEGES ON *.* TO USERNAME@'YOUR_PUBLIC_IP' IDENTIFIED BY 'PASSWORD';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit

Note:

With *.* you can access all databases. If you only want the CDR database you must write asterisk.*