当前位置:Gxlcms > 数据库问题 > mysql ERROR 1045 (28000): Access denied for user解决方法

mysql ERROR 1045 (28000): Access denied for user解决方法

时间:2021-07-01 10:21:17 帮助过:2人阅读

1045 (28000): Access denied for user root@localhost (using password: YES)

解决方法:

编辑mysql配置文件my.ini(一般在mysql目录下,不知道在哪请搜索),在[mysqld]这个条目下加入

skip-grant-tables

保存退出后重启mysql

  1.点击“开始”->“运行”(快捷键Win+R)。
  2.启动:输入 net stop mysql
  3.停止:输入 net start mysql

这时候在cmd里面输入mysql -u root -p就可以不用密码登录了,出现password:的时候直接回车可以进入,不会出现ERROR 1045 (28000),但很多操作都会受限制,因为我们不能grant(没有权限)。
1.进入mysql数据库:

mysql> use mysql;

2.给root用户设置新密码,蓝色部分自己输入:

mysql> update user set password=password("新密码") where user="root";
Query OK, 1 rows affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

3.刷新数据库

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

4.退出mysql:

mysql> quit
Bye


改好之后,再修改一下my.ini这个文件,把我们刚才加入的"skip-grant-tables"这行删除,保存退出再重启mysql就可以了。

mysql ERROR 1045 (28000): Access denied for user解决方法

标签:

人气教程排行