Ubuntu 18.04 重置mysql密码

1

停止mysql, 重启并绕过安全检测

sudo /etc/init.d/mysql stop
sudo mysqld_safe --skip-grant-tables &

2

如果出现'/var/run/mysqld' for UNIX socket file don't exists

mkdir -p /var/run/mysqld
chown mysql:mysql /var/run/mysqld

直到 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

3

use mysql;

update user set authentication_string=PASSWORD("mynewpassword") where User='root';

flush privileges;

quit

5.7

https://blog.csdn.net/lynnyq/article/details/80296137
重启服务器

你可能感兴趣的:(Ubuntu 18.04 重置mysql密码)