error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' — Missing /var/run/mysqld/mysqld.sock

后端 未结 30 2216
日久生厌
日久生厌 2020-11-22 10:49

My problem started off with me not being able to log in as root any more on my mysql install. I was attempting to run mysql without passwords turned on... but whenever I

相关标签:
30条回答
  • 2020-11-22 11:28

    This error occurs due to multiple installations of mysql. Run the command:

    ps -A|grep mysql
    

    Kill the process by using:

    sudo pkill mysql
    

    and then run command:

    ps -A|grep mysqld
    

    Also Kill this process by running:

    sudo pkill mysqld
    

    Now you are fully set just run the following commands:

    service mysql restart
    mysql -u root -p
    

    Have very well working mysql again

    0 讨论(0)
  • 2020-11-22 11:28

    I just had this problem on Ubuntu 14.10

    Turns that mysql-server was no longer installed (somehow it had been removed) but I couldn't just install it because there were some broken packages and dependency issues/conflicts.

    In the end I had to reinstall mysql

    sudo apt-get remove mysql-client
    sudo apt-get install mysql-server
    
    0 讨论(0)
  • 2020-11-22 11:29

    I think your MySQL server has not started. So start the server using one of the following commands.

    #services mysql start
    

    or

    #/etc/init.d/mysql start
    
    0 讨论(0)
  • 2020-11-22 11:30

    Try this command,

    sudo service mysql start
    
    0 讨论(0)
  • 2020-11-22 11:30

    My solution;

    Ubuntu 18.04 (WSL)

    /etc/mysql/my.cnf

    !includedir /etc/mysql/conf.d/
    !includedir /etc/mysql/mysql.conf.d/
    

    /etc/mysql/mysql.conf.d/mysqld.cnf

    [mysqld]
    user            = mysql
    pid-file        = /var/run/mysqld/mysqld.pid
    socket          = /var/run/mysqld/mysqld.sock
    port            = 3306
    

    I changed the port. It's worked for me. You can write another port. Example 3355

    0 讨论(0)
  • 2020-11-22 11:32

    Temporary Solution

    Maybe someone facing this problem. I am using Mysql Workbench on Ubuntu 14 and got this error.

    mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when trying to connect
    

    Find your socket file by running sudo find / -type s, in my case it was /run/mysqld/mysqld.sock

    So, I just created a link to this file in tmp directory.

    sudo ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
    
    0 讨论(0)
提交回复
热议问题