ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysql.sock' (2)

后端 未结 30 1457
再見小時候
再見小時候 2020-11-30 23:15

I\'m getting this error

ERROR 2002 (HY000): Can\'t connect to local MySQL server through socket \'/var/run/mysqld/mysql.sock\' (2)

even though

相关标签:
30条回答
  • 2020-12-01 00:02

    There is another chance of you to get this particular error if you modify the max_connections in my.cnf file.

    I also faced the same error which did not let me log in to MySQL server. In my case the problem was, I had to increase the max_connections size in

    /etc/mysql/my.cnf

    to

    set-variable = max_connections = 5000
    

    Due to this reason next day when I stared MySQL server it threw this error

    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
    

    Removing the set-variable = max_connections = 5000 segment from my.conf file did the trick. After removing that particular segment following command was used. MySQL server started up and running like previously.

    sudo /etc/init.d/mysql start
    
    0 讨论(0)
  • 2020-12-01 00:02

    make sure the bind address configuration option in the my.cnf file in /etc/ is the same with localhost or virtual serve ip address. plus check to make sure that the directory for creating the socket file is well specified.

    0 讨论(0)
  • 2020-12-01 00:02

    I was stuck with this error too, and it took almost 3 hours to find it.

    First of all, try to recall the changes that you made to your conf file, then undo the changes and save the file and start mysql. If you want to make any changes to the conf file, then stop mysql server and then change the desired values and restart mysql.

    This error occurs because of an incorrect (wrong keyword or wrong value assigned) change made to the conf file. Most of the times this error occurs even if you restart the machine running the server, as the server is stopped, in that case, start mysql server.

    0 讨论(0)
  • 2020-12-01 00:03

    This provides an alternative solution if the issue relates to you. If your disk drive is full than the MYSQL server (and most other programmes) is unable to start. Delete files and folders to allow Mysql-server to start up.

    0 讨论(0)
  • 2020-12-01 00:04

    recently i have faced with this error in my mysql ERROR 2002 (HY000):

    Can't connect to local MySQL server through socket

    '/var/lib/mysql/mysql.sock' (111)

    because i forget to start my mariadb. just type this command on ur terminal.

    systemctl start mariadb.service
    
    0 讨论(0)
  • 2020-12-01 00:04

    You don't need to reinstall MySQL server I was facing the same issue but I have resolved the issue by running these commands.

    1. ps -A|grep mysql
    2. sudo pkill mysql
    3. ps -A|grep mysqld
    4. sudo pkill mysqld
    5. sudo service mysql restart
    6. mysql -u root -p
    0 讨论(0)
提交回复
热议问题