This error message is generated by the client (not the server) because a connection to the server was made, but the server could not be reached.
There are various possible reasons:
1) check that mysqld is running on the server:
ps -ef | grep mysqld
should return something like:
root 2435 2342 0 15:49 pts/1 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/var/ --user=mysql mysql 2480 2435 0 15:49 pts/1 00:00:00 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/var/ --user=mysql ...
To start the daemon service, start redhat / fedora / centos:
service mysqld start
or in the Fedora release> = 16, which depends on systemd:
systemctl start mysqld.service
and to enable the daemon to start automatically when the system boots:
systemctl enable mysqld.service
2) check the port on which mysqld is running on the server:
netstat -lnp | grep mysql
should return:
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2480/mysqld unix 2 [ ACC ] STREAM LISTENING 8101 2480/mysqld /tmp/mysql.sock
the latter is a socket for local connections, the former is the TCP port for the network (3306 by default). If the port is not the default port, you must set the connection port on the client. When using mysql client:
mysql dbname -uuser -ppasswd -P<port> ...
3) located on a different network address, check that the server is listening on the network add to which you are connecting: in the /etc/my.cnf file /etc/my.cnf find the line:
bind_address=127.0.0.1
if the address 127.0.0.1 only local connections are allowed; if it was 172.16.1.0, you could not connect to 172.16.2.xxx
4) check that the server does not have a firewall and block connections to the mysql port (3306 is the default port); if it runs redhat / fedora / centos
service iptables status