error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' -- Missing /var/run/mysqld/mysqld.sock

  • 3,000
  • Tác giả: admin
  • Ngày đăng:
  • Lượt xem: 3
  • Tình trạng: Còn hàng

My problem started off with mạ not being able đồ sộ log in as root any more on my mysql install. I was attempting đồ sộ lập cập mysql without passwords turned on... but whenever I ran the command

# mysqld_safe --skip-grant-tables &

I would never get the prompt back. I was trying đồ sộ follow these instructions đồ sộ recover the password.

The screen just looks lượt thích this:

root@jj-SFF-PC:/usr/bin# mysqld_safe --skip-grant-tables
120816 11:40:53 mysqld_safe Logging đồ sộ syslog.
120816 11:40:53 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

and I don't get a prompt đồ sộ start typing the SQL commands đồ sộ reset the password.

When I kill it by pressing CTRL + C, I get the following message:

error: 'Can't connect đồ sộ local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'

Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!

If I retry the command and leave it long enough, I vì thế get the following series of messages:

root@jj-SFF-PC:/run/mysqld# 120816 13:15:02 mysqld_safe Logging đồ sộ syslog.
120816 13:15:02 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
120816 13:16:42 mysqld_safe mysqld from pid tệp tin /var/run/mysqld/mysqld.pid ended

[1]+  Done                    mysqld_safe --skip-grant-tables
root@jj-SFF-PC:/run/mysqld#

But then if I try đồ sộ log in as root by doing:

# mysql -u root

I get the following error message:

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

I checked and /var/run/mysqld/mysqld.sock tệp tin doesn't not exist. The thư mục does, but not the tệp tin.

Also, I don't know if this helps or not, but I ran find / -name mysqld and it came up with:

/var/run/mysqld - folder
/usr/sbin/mysqld - file
/run/mysqld - folder

I don't know if this is normal or not. But I'm including this info just in case it helps.

I finally decided đồ sộ uninstall and reinstall mysql.

apt-get remove mysql-server
apt-get remove mysql-client
apt-get remove mysql-common
apt-get remove phpmyadmin

After reinstalling all packages again in the same order as above, during the phpmyadmin install, I got the same error:

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

So I tried again đồ sộ uninstall/reinstall. This time, after I uninstalled the packages, I also manually renamed all mysql files and directories đồ sộ mysql.bad in their respective locations.

/var/lib/mysql 
/var/lib/mysql/mysql
/var/log/mysql
/usr/lib/perl5/DBD/mysql
/usr/lib/perl5/auto/DBD/mysql
/usr/lib/mysql
/usr/bin/mysql
/usr/share/mysql
/usr/share/dbconfig-common/internal/mysql
/etc/init.d/mysql
/etc/apparmor.d/abstractions/mysql
/etc/mysql

Then I tried đồ sộ reinstall mysql-server and mysql-client again. But I've noticed that it doesn't prompt mạ for a password. Isn't it supposed đồ sộ ask for an admin password?