忘记mysql root密码,或者不知道密码
报错:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES
解决方案:
首先关闭mysql服务
service mysqld restart
在[mysqld]的中插入:
skip-grant-tables
重启mysql服务:
service mysqld restart
进入mysql:
mysql
选择mysql数据库:
use mysql;
修改root密码:
UPDATE user SET authentication_string = password ( 'newPasswd' ) WHERE User = 'root'
刷新mysql权限:
flush privileges;
退出mysql后重启mysql服务就可以正常使用了。
想要修改用户权限时,发现了如下错误
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
解决方法:
set password=password('A1an_Tur!ng3');
mysql允许root远程登陆()
grant all privileges on *.* to root@'%' identified by 'A1an_Tur!ng3';
刷新mysql权限:
flush privileges;