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

后端 未结 30 2215
日久生厌
日久生厌 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:24

    Why getting this error

    I received new updates of mysql libraries so i updated my Kubuntu OS after that getting these errors.


    Commands i tried and how i fixed it.

    MySql-server is running correctly but when i tried to connect its giving

    Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'.
    

    I checked /var/run/mysqld/mysqld.sock'. this directory. My files did not existed.

    I also tried these commands to connect but did not worked for me.

     mysql -h 127.0.0.1 -P 3306 -u root -p
    
     sudo service mysql start
    

    After wasting round about 2 hours i found the solution

    sudo apt-get clean
    sudo apt-get update
    sudo apt-get upgrade -f
    

    After that everything fixed for me.

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

    This was mentioned a couple of times already, but this worked immediately for me:

    service mysql restart

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

    The solution is way easier.

    1. First, you have to locate(in Terminal with "sudo find / -type s") where your mysql.sock file is located. In my case it was in /opt/lampp/var/mysql/mysql.sock
    2. Fire up Terminal and issue sudo Nautilus
      This starts your Files manager with super user privileges
    3. From Nautilus navigate to where your mysql.sock file is located
    4. Right click on the file and select Make Link
    5. Rename the Link File to mysqld.sock then Right click on the file and Cut it
    6. Go to /var/run and create a folder called mysqld and enter it
    7. Now right click and Paste the Link File
    8. Voila! You will now have a mysqld.sock file at /var/run/mysqld/mysqld.sock :)
    0 讨论(0)
  • 2020-11-22 11:27

    I faced same error and found that it was due to upgradation of packages, So after restarting my system I resolved error.

    I think due to sql libraries/ packages update that error occured, So try this if you are doing some upgrading :)

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

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

    solutions

    finally uninstall and reinstall mysql. **

    • sudo apt-get remove mysql-server
    • sudo apt-get remove mysql-client
    • sudo apt-get remove mysql-common
    • sudo apt-get remove phpmyadmin

    then install again by

    • sudo apt-get install mysql-server-5.6

    After this operation, 164 MB of additional disk space will be used.

    • Do you want to continue? [Y/n] Y press YES for complete installations

    ...... .......

    • At last you will get these lines....

      Setting up libhtml-template-perl (2.95-1) ...

      Setting up mysql-common-5.6 (5.6.16-1~exp1) ... Processing triggers for libc-bin (2.19-0ubuntu6) Processing triggers for ureadahead (0.100.0-16) ...

    • And then

      root@ubuntu1404:~# mysql -u root -p (for every password first u should use )

    • Enter password:

    • Note :Entered password should be same as the installation time password of mysql(like .root,system,admin,rahul etc...)

      Then type

    • USE rahul_db(database name);

    Thanks.**

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

    you can find mysqld.sock in /var/run/mysqld if you have already installed mysql-server by sudo apt-get install mysql-server

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