mysql忘记root密码

mysql忘记root密码

redhat用rpm安装完mysql后,找不到root默认密码,只好重置root密码

#service mysqld stop   
#/usr/sbin/mysqld --user=mysql --skip-grant-tables &
#mysql  (默认以root进入mysql)
use mysql;
mysql>UPDATE user SET password=PASSWORD('123456') where User='root' and host='localhost';
mysql>FLUSH PRIVILEGES;
mysql>\q

出现You must SET PASSWORD before executing this statement

SET PASSWORD = PASSWORD('123456');

mysql> create user root@'%' identified by '123456';

mysql> grant all privileges on *.* to 'root'@'%' with grant option;

mysql> flush privileges;

你可能感兴趣的:(mysql)