1and1 Help Centre Categories

print article

Enable Remote Connections to MySQL

For 1&1 Dedicated Server

Follow the steps below to enable remote connections to your MySQL databases.

Please note:
Some 1&1 Dedicated Server with Root access may come with the MySQL remote access disabled. If you would like to enable this access, it is done at your own risk and 1&1 assumes no responsibility for any damages as a result of enabling this access.
Step 2
Open the "/etc/my.cfg" file by using the following command.
vi /etc/my.cnf
Step 3
Comment out the skip-networking by pressing i to insert text and precede the line with a hash(#) sign.
[mysqld]
default-character-set=latin1
datadir=/var/lib/mysql
socket=/var/lib/mysq/mysql.sock
skip-innodb
#skip-networking

[mysql.server]
user=mysql
basedir=/var/lib
[safe_mysqld]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
Step 4
Press Esc, type :x and press Enter to quit and save the changes.
Step 5
Log into your MySQL Database by typing the following command into the shell:
root@serverName:~$ mysql -u admin -p

This will log you into MySQL after prompting for a password. You will now see a MySQL prompt.
Step 6
Type the following at the MySQL prompt to select the MySQL database:
mysql> use mysql;
Step 7
Grant access to the database based on IP address by using the following commands, replacing the IP addresses and Database Names with the respective information. Hit Enter after every semicolon.
mysql> update db set Host='123.123.123.123' where Db='yourdatabasename';
mysql> update user set Host='123.123.123.123' where user='yourdatabaseUsername';

Alternately, you may specify to allow connections from any IP address by using the percent sign(%).
mysql> update db set Host='%' where Db='yourdatabasename';
mysql> update user set Host='%' where user='yourdatabaseUsername';
Step 8
Logout of MySQL with the exit command mysql> exit and press Enter.
Step 9
Restart the MySQL database with root@serverName:~$ /etc/rc.d/init.d/mysqld restart.
Step 10
You may now test the connection using Telnet by running the following line in a command prompt.
C:\Documents and Settings\userName> telnet 123.123.123.123 3306
Please note:
Microsoft Windows Vista does not have Telnet installed by default.
For additional information, you may want to reference: