十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
本篇内容介绍了“怎么解决MySQL中的ERROR 1045 (28000)错误问题”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
成都创新互联是一家专注于成都网站制作、网站设计、外贸网站建设与策划设计,白山网站建设哪家好?成都创新互联做网站,专注于网站建设十年,网设计领域的专业建站公司;建站业务涵盖:白山等地区。白山做网站价格咨询:13518219792一、错误描述:
错误如标题:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)。我用root@localhost授权登陆,然后给其中
一个用户授权,然后报如上错误:
[mysql@centos6-clone ~]$ mysql -u root -p
Enter password:
Your MySQL connection id is 2
Server version: 5.6.25-log MySQL Community Server (GPL)
mysql> grant all on *.* to 'fi'@'127.0.0.1' identified by "fi";
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
mysql> exit
Bye
按理来说,root@localhost是最高权限。居然不能给其他人授权。1045错误是授权拒绝。怎么办?
二、错误分析
查看下root权限:
mysql> show grants;
+----------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost |
+----------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*E74858DB86EBA20BC33D0AECAE8A8108C56B17FA' |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION |
+----------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
我们看root@localhost 有权限:ALL PRIVILEGES,但是没有WITH GRANT OPTION 语句,就是别人授权的权限。所以,不能授权的原因是:
没有这个WITH GRANT OPTION 语句。
三、错误解决
知道原因了,解决问题就很简单了。用另外一个方式登录root@127.0.0.1,然后给root@localhost授权,这样root@localhost 就可以给其他用户
授权了。
[mysql@centos6-clone ~]$ mysql -uroot -p -h227.0.0.1
Enter password:
mysql> SHOW GRANTS
-> ;
+----------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@127.0.0.1 |
+----------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY PASSWORD '*E74858DB86EBA20BC33D0AECAE8A8108C56B17FA' WITH GRANT OPTION |
+----------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*E74858DB86EBA20BC33D0AECAE8A8108C56B17FA' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
[mysql@centos6-clone ~]$ mysql -uroot -p
Enter password:
mysql> grant all on *.* to 'fo'@'%' identified by "fo";
Query OK, 0 rows affected (0.00 sec)
“怎么解决MySQL中的ERROR 1045 (28000)错误问题”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联-成都网站建设公司网站,小编将为大家输出更多高质量的实用文章!