Yesterday when I reinstalled Ubuntu and forgot to test MySQL after I configured Django and Pycharm, I ran into a problem with the configuration today:
ERROR 2003 (HY000): Can ' t connect to MySQL server on ' (IP address) ' (111) fix cannot connect to MySQL serversThis is a link to MySQL FAQ
Here are the basic steps to handle it.
1. If the database server is on a remote computer, then try to use the test client-server Connection ping
command, for example:
$ ping Server_ip_address
Ping Host
Once there is a connection, use the ps
command below to display information about the selected active process, in conjunction pipe
with the grep command, to check that the MySQL server can run on the system.
-Af| grep mysqld
Among the options:
-A
-Activate selection of all processes
-f
-Support full format listing
Check the MySQL process
If there is no output from the previous command, start the MySQL service as follows:
$ sudo systemctl start MySQL. service$ sudo systemctl start mariadb. Serviceor# sudo/etc/init.d/mysqld Start
After starting the MySQL service, try to access the database server:
---
Among the options:
-l
-Display the Listening port
-n
-Make digital address display
-p
-Represents the PID and the name of the program that owns the socket
Find MySQL port number
Therefore, use the -P
option to specify the port to access the database server from the output:
----P Port
3. If all of the above commands run successfully, but you still see the error, open the MySQL configuration file.
$ VI/etc/MySQL/my.cnfor$ vi / etc / mysql / mysql conf d / mysqld cnf
Look for the offline and use its commented out #
characters:
Bind-=127.0. 0.1
Save the file and exit, and then restart the MySQL service as follows:
$ sudo systemctl start MySQL. service$ sudo systemctl start mariadb. Serviceor# sudo/etc/init.d/mysqld Start
This will solve the problem.
That's it! What if you know other methods or have suggestions for troubleshooting MySQL connection errors?
Please let me know.
ERROR 2003 (HY000): Can ' t connect to MySQL server on ' 127.0.0.1 ' (111) fix could not connect to MySQL servers