Issue:
When attempting to establish a connection to a MySQL server at '127.0.0.1' using the 'mysql' command, the following error occurs:
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
Solution:
For Ubuntu (without MySQL replication enabled):
Locate the line 'bind-address = 127.0.0.1' and comment it out by adding a '#' symbol at the beginning of the line:
# bind-address = 127.0.0.1
For cases where MySQL replication is enabled:
Instead of connecting to 'localhost' or '127.0.0.1', specify the IP address for which the MySQL server is configured to bind to in the 'my.cnf' file.
The above is the detailed content of Why Can't I Connect to My MySQL Server (Error Code 2003)?. For more information, please follow other related articles on the PHP Chinese website!