Search Our Database

How to setup a remote MySQL server in Directadmin based Linux server

Last updated on |
by

Sometime you may need to use a remote MySQL server in you Directadmin server. The below steps will help you to perform this configuration:

1. SSH to your web server as root.

2. Edit /usr/local/directadmin/conf/mysql.conf to add in the IP of the remote MySQL server as host:

user=da_admin

host=xx.xx.xx.xx

passwd=H&*(h@123

Where xx.xx.xx.xx is an IP address of the remote MySQL server

3. SSH to your remote mysql server, make sure mysql service is installed, you can test it by:

mysqld -V

If nothing is showing, you will need to install it

mkdir mysql
cd mysql
wget http://files.directadmin.com/services/all/mysql/64-bit/5.5.11/MySQL-shared-5.5.11-1.linux2.6.x86_64.rpm
wget http://files.directadmin.com/services/all/mysql/64-bit/5.5.11/MySQL-devel-5.5.11-1.linux2.6.x86_64.rpm
wget http://files.directadmin.com/services/all/mysql/64-bit/5.5.11/MySQL-client-5.5.11-1.linux2.6.x86_64.rpm
wget http://files.directadmin.com/services/all/mysql/64-bit/5.5.11/MySQL-server-5.5.11-1.linux2.6.x86_64.rpm
rpm -Uvh MySQL-*

4. Login to mysql service in remote mysql server.

mysql -uroot -p

5. Grant full privileges to da_admin.

GRANT ALL PRIVILEGES ON *.* TO da_admin@xxx.xxx.xxx.xxx IDENTIFIED BY 'H&*(h@123' WITH GRANT OPTION;
FLUSH PRIVILEGES;
quit

Take note that xxx.xxx.xxx.xxx is the IP of you webserver, you are granting permission to let the webserver to access to your remote mysql server.

6. Test below command in the webserver to check if webserver can access to remote mysql server now.

mysql -uda_admin -p --host=xxx.xxx.xxx.xxx

7. Test in Directadmin if the webserver can create and manage databases via Mysql Management.

8. To allow  phpmyadmin to access a remote mysql databases, please edit:

/var/www/html/phpMyAdmin/config.inc.php

Find this line:

$cfg['Servers'][$i]['host']          = 'localhost'; // MySQL hostname or IP address

And change it to:

$cfg['Servers'][$i]['host']          = 'xx.xx.xx.xx'; // MySQL hostname or IP address