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

来源:互联网 发布:长城三公主知乎 编辑:程序博客网 时间:2024/05/01 19:16

 这一句话就行了:      编辑mysql配置文件my.ini(不知道在哪请搜索),在[mysqld]这个条目下加入 
  skip-grant-tables 保存退出后重启mysql  


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

 
问题重现(以下讨论范围仅限Windows环境):  
C:\AppServ\MySQL> mysql -u root -p Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)  
编辑mysql配置文件my.ini(不知道在哪请搜索),在[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; Database changed  
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就可以了
0 0
原创粉丝点击