Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (38)

后端 未结 30 2349
再見小時候
再見小時候 2020-11-22 04:23

I am having a big problem trying to connect to mysql. When I run:

/usr/local/mysql/bin/mysql start

I have the following error :

<         


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

    I was getting the error because I was running MAMP and my .sock file was in a different location. I just added a symbolic link where the app thought it should be that pointed to where it actually was and it worked like a charm.

    0 讨论(0)
  • 2020-11-22 04:50

    If your file my.cnf (usually in the /etc/mysql/ folder) is correctly configured with

    socket=/var/lib/mysql/mysql.sock
    

    you can check if mysql is running with the following command:

    mysqladmin -u root -p status
    

    try changing your permission to mysql folder. If you are working locally, you can try:

    sudo chmod -R 755 /var/lib/mysql/
    

    that solved it for me

    0 讨论(0)
  • 2020-11-22 04:51

    I had the same problem and it has been caused by an update of mysql drivers when mysql server was running. I fixed it just restarting both mysql and apache2:

    sudo service mysql stop

    sudo service mysql start

    sudo service apache2 stop

    sudo service apache2 start

    0 讨论(0)
  • 2020-11-22 04:51
    sudo service mysqld start
    

    Worked for me, I'm using Centos

    0 讨论(0)
  • 2020-11-22 04:51

    This was good enough for me

    sudo /etc/init.d/mysql restart
    
    0 讨论(0)
  • 2020-11-22 04:52

    If everything worked just fine and you just started seeing this error, before you do anything else, make sure you're not out of disk space:

    df -h
    

    If the volume where the mysql.sock is being created is at 100% use, MySql won't be able to create it and this will be the cause of this error. All you need to do is delete something that's not needed, like old log files.

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