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

前端 未结 30 1031
离开以前
离开以前 2020-11-22 02:25

I installed LAMP on Ubuntu 12.04 LTS (Precise Pangolin) and then set root password on phpMyAdmin. I forgot the password and now I am unable to login. When I try to chan

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

    I got this problem too, but I just did:

    sudo service mysql restart 
    

    It worked for me.

    0 讨论(0)
  • 2020-11-22 03:02

    Make sure you have backups of important databases and then try uninstall MySQL related stuff:

    apt-get remove --purge mysql\*
    

    Then install it again:

    apt-get install mysql-server mysql-client
    

    This worked for me and data was kept.

    If PHP MySQL shows errors you might have to reinstall PHP MySQL:

    apt-get install php5-fpm php5-mysql
    
    0 讨论(0)
  • 2020-11-22 03:02

    I also facing same problem it will be occur if your mysql server is not running by default it will again stop after some sec so you again run ($ sudo service mysql start ) command you can change if know.

    for that use command

    $ sudo service mysql start   
    

    (put user password if required because we use sudo ) and then run

    $ sudo mysql -u root -p          (put user password if required )
    

    now you got your database

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

    I solved this by killing the mysql process:

    ps -ef | grep mysql
    kill [the id]
    

    And then I started the server again with:

    sudo /etc/init.d/mysql restart
    

    But start works as well:

    sudo /etc/init.d/mysql start
    

    Then I logged in as admin, and I was done.

    0 讨论(0)
  • 2020-11-22 03:05

    In my case it worked by doing some R&D:

    I am able to connect to MySQL using

    root-debian#mysql -h 127.0.0.1 -u root -p
    

    But it's not working with mysql -u root -p.

    I did not find any bind-address in my.cnf. So I outcommented the parameter socket=/var/lib/mysql/mysqld.sock in my.cnf which was causing me a problem with login.

    After restarting the service it went fine:

    root@debian:~# mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 5
    Server version: 5.6.19 MySQL Community Server (GPL)
    
    0 讨论(0)
  • 2020-11-22 03:06

    I tried the following steps:

    1. Log in as super user or use sudo
    2. Open /etc/mysql/my.cnf using gedit
    3. Find bind-address, and change its value to the database server host machine's IP address. For me, it was localhost or 127.0.0.1
    4. Save and close the file.
    5. Come back to terminal and execute sudo service mysql start

    And it worked for me.

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