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;

posted @ 2015-02-13 14:32  wardensky  阅读(165)  评论(0编辑  收藏  举报