connect to local MySQL server through socket

前端 未结 6 1954
不知归路
不知归路 2020-12-05 21:01

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

I tried everything I found o

相关标签:
6条回答
  • 2020-12-05 21:34

    If you have multiple mysql servers installed then make sure you run the correct MYSQL or change your path settings. For example:

    /opt/lampp/bin/mysql -u root -p 
    

    I have XAMPP installed , the solution worked for me.

    0 讨论(0)
  • 2020-12-05 21:36

    It looks like either it can't create a file in /var/lib/mysql/. If you look at the errode 13, it is generally means permission errors.

    1) Make sure that mySQL can write to the directory /var/lib/mysql and/or that mySQL owns that directory. Do a:

    cd /var/lib ; ls -la | grep mysql
    

    To be sure.

    2) If you are trying to start with the mySQL user, start it with root instead (You probably are, but it's worth checking).

    3) If you are running something like SElinux, make sure that you enable it for mySQL access. I doubt that is the case, but it's worth checking.

    4) Small note: Don't create the sock file - mysql will create one once it is up and running properly. If it still in the run directory, delete it.

    0 讨论(0)
  • 2020-12-05 21:41

    Try to kill the socket with (this may depend on your OS)

    rm /var/lib/mysql/mysql.sock rm: remove socket `/var/lib/mysql/mysql.sock'? y restart the service

    service mysqld start

    0 讨论(0)
  • 2020-12-05 21:42

    Your log actually tells you the issue:

    mysqld: Too many arguments (first extra is 'start').

    Just start the daemon without the word 'start'. Instead of:

    sudo /usr/sbin/mysqld start

    it should be just:

    sudo /usr/sbin/mysqld

    0 讨论(0)
  • 2020-12-05 21:45

    I did experiments and finally solve it with these commands

    sudo chown mysql:root /var/lib/mysql/ -R
    sudo chmod g+rw /var/lib/mysql/ -R
    sudo /usr/sbin/mysqld --skip-grant &
    

    It get running...... Hurraaahhhhhhhhhh!!!!!!!!!!!!

    0 讨论(0)
  • 2020-12-05 21:50

    Have you tried?

    sudo touch /etc/apparmor.d/local/usr.sbin.mysqld
    

    More background info here: https://askubuntu.com/a/127029

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