mysql修改root密码

1、如果知道root密码:

mysql -u root -p  

输入密码 

use mysql;

UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';

FLUSH PRIVILEGES;

quit;

 

2、如果不知道密码

service mysqld stop;

mysqld_safe --skip-grant-tables&mysql -u root mysql;
UPDATE user SET password=PASSWORD("new password") WHERE user='root';
FLUSH PRIVILEGES;
 
password字段没有的话:
update mysql.user set authentication_string=password('新密码') where user='root';
FLUSH PRIVILEGES;
 
 
 
posted on 2018-10-27 11:43  _故乡的原风景  阅读(139)  评论(0编辑  收藏  举报