ERROR 2003 (HY000): Can ' t connect to MySQL server on ' 127.0.0.1 ' (111) fix could not connect to MySQL servers

Source: Internet
Author: User

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:
    1. -A-Activate selection of all processes
    2. -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:
    1. -l-Display the Listening port
    2. -n-Make digital address display
    3. -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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.