Mysql 密码修改 linux 忘记密码 新建用户 更新密码

#mysql -u root -p

#输入数据库密码

#select user, host from mysql.user;

#SET PASSWORD FOR 'root'@'localhost' = PASSWORD('新密码');//本地密码

#SET PASSWORD FOR 'root'@'%' = PASSWORD('新密码');//远程密码

#FLUSH PRIVILEGES;// 刷新生效

 

mysql 忘记密码:(如果中间出错, 就使用FLUSH PRIVILEGES命令)

#service mysqld stop //或者 #service mysql stop

#mysqld_safe --skip-grant-tables //进入到skip-grant-tables模式

#mysql

#use mysql

#SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');//本地密码

#SET PASSWORD FOR 'root'@'%' = PASSWORD('123456');//远程密码

#FLUSH PRIVILEGES;// 刷新生效

#ps -ef | grep mysql

#kill -9 mysql的id

#service mysqld start