Mysql can't connect remotely
From Initq
I was trying to connected to mysql remotely using my local client and was getting the following error:
qais@qais:~$ mysql -u admin -h 192.168.168.5 -p Enter password: ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.168.5' (111)
I did an nmap and telnet test to port 3306 and was unable to connect. There were no iptables installed so i ruled that out. The mysqld was running on a debian system so i started checking the config files. they were located in /etc/mysql. I edited the my.cnf file and inserted a new bind line.
communication:/etc/mysql# pwd /etc/mysql communication:/etc/mysql# ls conf.d debian.cnf debian-start my.cnf communication:/etc/mysql# vi my.cnf # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. #bind-address = 127.0.0.1 bind-address = 0.0.0.0
Restart the mysqld in the debian box. Then go to my client box and:
qais@qais:~$ /sbin/ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:0b:cd:00:61:a5 inet addr:192.168.168.81 Bcast:192.168.168.255 Mask:255.255.255.0 inet6 addr: fe80::20b:cdff:fe00:61a5/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:33946884 errors:0 dropped:0 overruns:0 frame:0 TX packets:3547937 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:3510780838 (3.2 GiB) TX bytes:425132774 (405.4 MiB) qais@qais:~$ mysql -u admin -h 192.168.168.5 -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 84 Server version: 5.0.51a-24+lenny3 (Debian) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | bugzilla3 | | mysql | +--------------------+ 3 rows in set (0.02 sec) mysql>