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

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

    The same error occured with my system as well. I had to remove mysql-server and reinstall it. Not other way around. Try running these commands it it works:

    1. sudo apt-get purge mysql-server
    2. sudo apt-get autoremove
    3. sudo apt-get install mysql-server
    0 讨论(0)
  • 2020-12-01 00:09

    My problem was solved checking if the process was running on Ubuntu 12.04

    ps ax | grep mysql
    

    Then the answer was that it wasn't running, so I did

    sudo service mysql start
    

    Or try

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

    If you look close, you'll see the difference:

    • The server listens on /var/run/mysqld/mysqld.sock
    • The client tries to connect to /var/run/mysqld/mysql.sock

    You'll have to adjust the one or the other.

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

    this worked for me

    sudo /etc/init.d/mysql start
    

    first i tried this, but i dont understand why it doesn't work this way

    sudo service mysql start
    
    0 讨论(0)
  • 2020-12-01 00:11

    I had the problem.

    This process worked for me:

    Ensure that during remove process you choose No to deleting database.

    sudo apt-get remove --purge mysql*
    
    sudo apt-get autoremove
    
    sudo apt-get autoclean
    
    sudo apt-get install mysql-server mysql-client
    
    0 讨论(0)
  • 2020-12-01 00:11

    Note that I ran into this trouble after I upgraded my Ubuntu 14.04 distribution using apt-get upgrade. I had to completely purge mysql-server and mysql-client and reinstall it to fix this issue.

    sudo apt-get autoremove
    sudo apt-get autoclean
    sudo apt-get purge mysql-server mysql-client
    sudo apt-get install mysql-server mysql-client
    

    Hope this helps.

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