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

后端 未结 30 1455
再見小時候
再見小時候 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:04

    On Debian this was a bind problem for me so changing bind-address from localhost to 0.0.0.0 helped.

    vim /etc/mysql/my.cnf 
    

    bind-address = 0.0.0.0

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

    I deleted everything connected to mysql with

    sudo apt-get remove --purge --auto-remove mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-5.7

    sudo rm -r /etc/mysql* /var/lib/mysql* /var/log/mysql*

    and then reinstalled it again with

    sudo apt-get update

    sudo apt-get install mysql-server

    and then started it with

    mysql -u root -p

    followed by the password

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

    In my case the problem was that I had added "default-character-set=utf8" to my.cnf and that was corrupting the file. Instead change that line for "character_set_server=utf8". That should solve it, hope this helps.

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

    I have follow Wellington Lorindo posting. And My problem was solved.

    Steps 1. run in terminal

    ps ax | grep mysql

    Result was

    11200 ? Ssl 0:01 /usr/sbin/mysqld

    11514 pts/0 S+ 0:00 grep mysql

    Steps 2. Again type this

    sudo service mysql start

    And problem solved.

    Thanks Wellington Lorindo

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

    Once you install or update MySQL, it won't ask you to create the root password. In that case: you will have file called "debian.cnf" path: /etc/mysql. You will find user name and password, login with that credentials and create new user and password.

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

    I had the same problem when i installed xampp on my system. The mysql server looks for /var/run/mysqld/mysqld.sock but the mysql.sock file was in xampp folder so i used

     find / -name '*.sock'
    

    to find the mysql.sock file and then used

    ln -s <the file location> /var/run/mysqld/mysqld.sock
    

    to get a link for the *.sock file then tried mysql and it ran without error. Hope this could solve yours.

    Remember to create the directory if it does not exists.

    0 讨论(0)
提交回复
热议问题