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

前端 未结 30 1247
南方客
南方客 2020-11-22 11:30

I am getting the following error when I try to connect to mysql:

Can\'t connect to local MySQL server through socket \'/var/lib/mysql/mysql.sock\' (2)<

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

    First enter "service mysqld start" and login

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

    In my case, I was importing a new database, and I wasnt able to connect again after that. Finally I realized that was a space problem.

    So you can delete the last database and expand you hard drive or what I did, restored a snapshot of my virtual machine.

    Just in case someone thinks that is useful

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

    MariaDB, a community developed fork of MySQL, has become the default implementation of MySQL in many distributions.

    So first you should start,

    $ sudo systemctl start mariadb
    

    If this fails rather try,

    $ sudo systemctl start mysqld
    

    Then to start mysql,

    $ mysql -u root -p
    

    As of today, in Fedora the package is named mariadb And in Ubuntu it is called mariadb-server.

    So you may have to install it if its not already installed in your system.

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

    Ensure that your mysql service is running

    service mysqld start
    

    Then, try the one of the following following:

    (if you have not set password for mysql)

    mysql -u root
    

    if you have set password already

    mysql -u root -p
    
    0 讨论(0)
  • 2020-11-22 11:57

    I had to disable explicit_defaults_for_timestamp from my.cnf.

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

    Please check whether another mysql service is running.

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