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

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

    There are many solutions to this problem but for my situation, I just needed to correct the DATE on the machine/server (Ubuntu 16.04 Server).

    i) Check the date of your server and correct it.

    ii) Run sudo /etc/init.d/mysql restart

    That should get it started.

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

    I've just had this problem. after a day of checking finally I've got the answer with that The mysql.sock file is created when MariaDB starts and is removed when MariaDB is shutdown. It won't exist if MariaDB is not running. maybe you didn't install MariaDB. YOU COULD FOLLOW THE INSTRUCTION BELOW: https://www.linode.com/docs/databases/mariadb/how-to-install-mariadb-on-centos-7 BEST

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

    In my case, I was using Centos 5.5. I found that the problem was because the mysql service was stopped some how. So I started mysql service with the command:

     /etc/init.d/mysqld start
    

    So.. silly mistake.

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

    For those whose any solution did not work, try:

    cd /etc/mysql
    

    check if my.cnf is present

    nano my.cnf
    

    and make sure you have only one bind-address as follows:

    bind-address = 127.0.0.1

    If not, that might be the problem, just exit nano and save the file.

    and service mysql start

    note that if you don't have nano (its a text editor) just install it with apt-get install nano and once in just press Ctrl+X to exit, dont forget to say Y to save and use the same file)

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

    I got the following error

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

    Tried several ways and finally solved it through the following way

    sudo gksu gedit /etc/mysql/my.cnf
    

    modified

    #bind-address       = 127.0.0.1
    

    to

    bind-address        = localhost
    

    and restarted

    sudo /etc/init.d/mysql restart
    

    it worked

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

    This doesn't directly answer your question but a subset of it, namely using PythonAnywhere. I kept stumbling upon this question when looking for a fix so I'm adding it here in the hope that it will help others in my situation.


    PythonAnywhere decided to change the database connection hostnames in order to improve efficiency and reliability, as detailed here:

    The official host name you should use for connecting to your account's MySQL database instance has changed from mysql.server to yourusername.mysql.pythonanywhere-services.com. This bypasses a part of our infrastructure that has started showing problems in recent weeks, and it should be much more efficient and reliable than the old way.

    Hence, you will need to update your hostname to the value highlighted above.

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