Press "Enter" to skip to content

重置mysql密码 5.7

转自 https://jingyan.baidu.com/article/3c48dd3425fbaba10be35893.html

my.cnf,在文件末尾编辑增加代码 skip-grant-tables

重启mysqld服务,登陆MySQL

$use mysql;

$select host,user,authentication_string from user;

#修改root密码

$update user set authentication_string = password(‘123456’) where user = ‘root’;

开启权限系统,重启MySQL,新密码登陆

$vim /etc/my.cnf

#开启权限系统

#skip-grant-tables

#重启mysql

$systemctl restart mysqld

#新root密码登陆

$mysql -uroot -p

发表评论