How to Enable remote access to MySQL
: This document is valid for 1&1 Web Hosting 5.0 but not for 1&1 Microsoft Hosting.
Linux Root Servers only!
As default, 1&1 dedicated Root servers come with the MySQL remote access disabled, this is for
security reasons, as it can be a security risk for the Server. If you would like to enable this
access it is done at your own risk and 1&1 take no responsibility for any damage cause as a result
of enabling this access.
Step 1 Firstly you will need to log into your server's shell via SSH. (For more information on how to access your server using SSH please see this FAQ :Remote Server Access Using Secure Shell (SSH))
Step 2 Once connected you need to open this file "/etc/my.cfg" this can be done using the command
vi /etc/my.cnf
Step 3 You will see a few lines of text. Comment out the 'skip-networking'
[mysqld] default-character-set=latin1 datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock skip-innodb #skip-networking <---- MAKE SURE this is commented like this with the # preceding. [mysql.server] user=mysql basedir=/var/lib [safe_mysqld] err-log=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
Step 4 Save and Close the file.
Step 5 Now you will need to log into your MySQL Database via the shell you have open.
To do this type the following command into the shell.
root@pxxxxx:~ mysql -u admin -pXXXXXX
This will log you into the MySQL database
Step 6 Type the following in:
mysql> use mysql;
Step 7 Next you will need to grant access to the database, this will be restricted by IP.
To do this use the the following commands, replacing the IP addresses and Database Names.
mysql> update db set Host='123.123.123.123' where Db='yourdatabasename'; mysql> update user set Host='123.123.123.123' where user='yourdatabaseUsername';
Please note
Replace 123.123.123.123 with your connecting IP address.
Step 8 Logout of MySQL with the 'exit' command.
mysql> exit
Step 9 Next restart the mysql database with the command :
root@pxxxxx :~ /etc/rc.d/init.d/mysqld restart
Step 10 Now test the connection with telnet from your local machine, by typing
telnet yourserverIPaddress 3306 and it will connect to your server at this port.