【转载】mysqld_safe Directory ‘/var/run/mysqld’ for UNIX socket file don’t exists.

This is about resetting the MySQL 5.7 root password in Ubuntu 16.04 LTS

You probably tried something like this:

sudo service mysql stop
mysqld_safe --skip-grant-tables &

And then got something like this (stangely, exists is misspelled in the output):

[1] 5599
2018-03-02T21:36:41.292413Z mysqld_safe Logging to syslog.
2018-03-02T21:36:41.294798Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2018-03-02T21:36:41.296902Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.

Then you tried to find the socket (takes a while):

sudo find / -type s

And /var/run/mysqld does not exist.

So you start mysql again and search and now it does exist!

sudo service mysql start
sudo find / -type s

[output:]
/run/mysqld/mysqld.sock
/run/dbus/system_bus_socket
/run/acpid.socket
/run/snapd-snap.socket
...

My guess is that mysql_safe can’t create the directory (which appears to be dynamically created when mysql starts). Solution:

sudo mkdir /var/run/mysqld 
sudo chown mysql:mysql /var/run/mysqld

Now run:

sudo service mysql stop
mysqld_safe --skip-grant-tables &
mysql -uroot mysql

When you get to the mysql prompt (don’t forget to change your pw before copy/pasting!!!):

UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='%';

exit;

then

sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
sudo service mysql start

OTHER SOLUTION (means restarting MySQL a couple times!):

Note: in MySQL 5.7 you may find that my.cnf actually references config files elsewhere:

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

So in my case:

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

Under [mysqld] add:

skip-grant-tables

Close the file and restart mysql, then…

sudo service mysql restart
sudo mysql -uroot mysql
(use query above...)

Edit mysqld.conf again, remove the line, then restart MySQL

sudo service mysql restart

Good luck!

转载于:https://www.cnblogs.com/liawne/p/9276939.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值