mysql连接报错ERROR 1045 (28000): Access denied for user ‘root’@’localhost‘ (using password: YES)
- 在mysql安装目录找到my.ini文件,在[mysqld]下添加skip-grant-tables,使其登录时跳过权限检查
- cmd重启mysql,net stop mysql net start mysql
- 登陆mysql,cmd输入 mysql -uroot -p ,输入密码部分直接回车就能登上mysql
1.查看数据库
show databases;
2.使用mysql数据库表
use mysql;
3.更新user表里边password
update user set Password="密码";
4.退出数据库
exit
5.把之前的配置文件改回来,使用密码登录,在my.ini中注释掉skip-grant-tables
6.重启mysql
net stop mysql net start mysql
7.输入密码登录
mysql -uroot -p密码
登陆报错ERROR 1130 (HY000): Host 'localhost' is not allowed to connect to this MySQL server
解决办法:
5. 再在my.ini中加上skip-grant-tables
6. 无密码登陆mysql
7. grant授权mysql> grant all privileges on *.* to root@'localhost' identified by "123456";
8. 报错ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
9. 刷新权限flush privileges;
然后再执行上面的授权命令
10.修改 my.ini,去掉skip-grant-tables
,重启mysql