View Full Version : Remote access ot Mysql on Centos
onmoon
10-19-2009, 11:35 PM
Finally moved to linux --centos 5.3 32bit. The installation is very easy and straight. Got everything done, PHP, Mysql, Apache, not the latest version, but working. Now, I want to remotely access this machine's Mysql database, but failed. Googled, not very helpful because I'm really new to linux. Seems many factors could affect this, such as firewall (say iptables), the privileges of mysql.
Please help or post some userful information here.
oracleguy
10-20-2009, 12:42 AM
The first place I would check is your MySQL configuration file. Network access can be enabled and disabled there. I don't know where it is on CentOS though. The file is called my.cnf, it might be under /etc/mysql but if it isn't, you can search for it.
onmoon
10-20-2009, 10:56 AM
oracleguy, thank you for your reply.
Many people say I need to comment on the line "--skip-networking", but I didn't find this line with my.cnf. So I think the network access is enabled..
onmoon
10-20-2009, 11:00 AM
And I also tried to give the remote address privileges within mysql.
mysql> grant all privileges on *.* to 'myuser'@'192.168.*.*' identified by 'mypwd';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
The cmd lines above is to grant my on of my lan IP, I also did one on a remote IP address, neither of them worked.
onmoon
10-20-2009, 11:05 AM
More symptoms:
After some unsuccessfully config and restart, I tried to access that machine via port 80, HTTP. I will open a PHP file via Wan or Lan, and the PHP will connect Mysql. The PHP scripts only work when I set the server host as "localhost", if not, such as its own LAN IP, the scripts will return errors like:
Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in /var/www/html/test.php on line 19
oracleguy
10-21-2009, 05:30 PM
What happens when you try to connect to the MySQL server from a different computer on the network? Does it say the connection was refused or timed out or did it give you an access denied message?
onmoon
10-21-2009, 06:39 PM
What happens when you try to connect to the MySQL server from a different computer on the network? Does it say the connection was refused or timed out or did it give you an access denied message?
Thank you for the reply. it is solved, but I didn't do anything, strange. After restart, it's just working as expected. but it doesn't need a restart...
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.