日期:2014-05-16  浏览次数:20722 次

mysql创建用户和忘记root密码
1.创建mysql用户
引用
grant  all on myidb.* to  myidb@'localhost' identified by'password';
revoke all on myidb.* from  myidb@'localhost';



说明:
除grant/revoke命令,其他与权限相关的修改都要执行flush privileges 才能生效。


2.修改mysql的root用户密码
引用
mysql>use mysql
mysql>update user set password=PASSWORD('Newpasswor') whereuser='root';
#/etc/rc.d/init.d/mysqld restart



3.忘记mysql的root密码
引用
1)vi /etc/my.cnf
2)在[mysqld]下加入一行 skip_grant_tables
3)#/etc/rc.d/init.d/mysqld restart
4)#mysql -u root
5)mysql>use mysql;
  mysql>update user setpassword=PASSWORD('Newpassword') where user='root'