Jump to Navigation

117 - Error 2003 (HY000): Can't connect to MySQL server on ...

If you have a message like :

$ mysql -u root -p<password> -h myserver

ERROR 2003 (HY000): Can't connect to MySQL server on 'myserver' (10061)

* Port check from the remote machine.

# nmap -sS -O -p 3306 '192.168.1.100'

If it opens the port, you get the message :

Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2012-02-09 11:01 PST
Warning:  OS detection will be MUCH less reliable because we did not find at least 1 open and 1 closed TCP port
Interesting ports on ntcweb2.ntcltdna.ad (192.168.1.100):
PORT     STATE SERVICE
3306/tcp open  mysql
Device type: general purpose|broadband router
Running (JUST GUESSING) : Linux 2.4.X|2.5.X|2.6.X (97%), D-Link embedded (95%)
Aggressive OS guesses: Linux 2.4.0 - 2.5.20 (97%), Linux 2.4.20 - 2.4.22 w/grsecurity.org patch (97%), Linux 2.4.22-ck2 (x86)   w/grsecurity.org and HZ=1000 patches (97%), Linux 2.4.7 - 2.6.11 (97%), Linux 2.4.18 - 2.4.20 (95%), Linux 2.4.18 - 2.4.21 (x86) (95%), Linux 2.4.19 w/grsecurity patch (95%), Linux 2.4.26 (95%), Linux 2.4.27 or D-Link DSL-500T (running linux 2.4) (95%), Linux 2.4.27 with grsec (95%)
No exact OS matches for host (test conditions non-ideal).

Nmap finished: 1 IP address (1 host up) scanned in 10.071 seconds

Please Check the following things  to slove the problem.

1. Check if mysqld is running or not in the  server.

# ps -ef | grep mysqld

# lsof -i -n -P | grep 3306

2. Check if the user for remote login.

mysql> select user,host from mysql.user;

If no user for the remote login, you need to create a user.

mysql> create user 'root'@'%' identified by '<password>';

or

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'welcome' WITH GRANT OPTION;

mysql> FLUSH PRIVILEGES;

3. Comment out the line in my.cnf

# bind-address    = 127.0.0.1 10.0.0/24

Other :

To fix this problem, open /etc/mysql/my.cnf and change binding ip address from 127.0.0.1
to the network address that the server takes on the network

bind-address        = 192.168.10.60

If your OS is "Ubuntu", try the following :

nind-address       = 0.0.0.0

( By default, the MySQL service listens only on the loopback interface. )

4. Check port for mysql (3306)

# iptables -L -n | grep ACCEPT

ACCEPT     tcp  --  172.16.0.0/12        0.0.0.0/0           tcp dpt:21
ACCEPT     tcp  --  172.16.0.0/12        0.0.0.0/0           tcp dpt:23

Open port # 3306 or disable the firewall.

5. Specify the port # if you configured for the login except 3306.

# mysql -u root -p<password> -h myserver -P 3306

 

 



Main menu 2

Story | by Dr. Radut