2003 - Can't connect to MySQL server on 'localhost' (10061)
When you are working with a MySQL database, you might run into this error:
2003 - Can't connect to MySQL server on '127.0.0.1' (or some other host)
There might be several causes for that error, so you can try these methods to find out what the problem is.
1. Check for typos
A small typo in the MySQL server name, database name, username, port, etc. can lead to this error, so make sure you got them right 100%.
2. Make sure MySQL server is running
Maybe the problem is that there is no MySQL server running at the specified host. So the first thing you should do is to verify the status of MySQL Server. It’s recommended to try restarting the MySQL server.
You might need to check the port that it’s listening to, the default port is 3306.
If you are using DBngin to manage the local server, launch DBngin and see if the server is still on. If not, start it.
3. Connection to the MySQL server is not allowed using TCP/IP
You need to make sure that your MySQL server was not started with the --skip-networking
option. You should find the setting in the MySQL configuration file (my.ini on Windows, my.cnf on Unix/Linux).
If it was, remove it and restart MySQL server for the change to take effect.
For remote connections, you need to confirm that MySQL remote access is enabled. By default, MySQL listens for connections only from localhost. Go check the MySQL configuration file and give the bind-address
as the IP address of the server where MySQL service listens.
You could also try increasing the max_connection
parameter in the MySQL configuration file.
4. There is a networking issue blocking access to MySQL
It could be a network firewall blocking the connection. Most often it will help to uninstall and reinstall the firewall.
5. Still no help at all?
If you tried all above and none of them worked, try connecting using SSH Tunnelling instead and see if it helps.
For more information, visit MySQL Reference Manual.
Need a good MySQL GUI? TablePlus provides a native client that allows you to access and manage MySQL and many other databases simultaneously using an intuitive and powerful graphical interface.
Not on Mac? Download TablePlus for Windows.
Need a quick edit on the go? Download for iOS