当前位置:   article > 正文

mysql 建库报匿名用户权限错误

匿名用户创建数据库被拒绝

报错信息:

ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'meitu'

系统环境:

  • Centos 7.5
  • Mysql Server version: 5.6.48

分析原因:匿名用户('')权限报错

问题描述:

安装好mysql后,root用户账户登录mysql,创建一个新数据库时,提示报错,如下:

  1. [root@localhost mysql]# mysql -uroot
  2. Welcome to the MySQL monitor. Commands end with ; or \g.
  3. Your MySQL connection id is 3
  4. Server version: 5.6.48 MySQL Community Server (GPL)
  5. Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
  6. Oracle is a registered trademark of Oracle Corporation and/or its
  7. affiliates. Other names may be trademarks of their respective
  8. owners.
  9. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  10. mysql> show databases;
  11. +--------------------+
  12. | Database |
  13. +--------------------+
  14. | information_schema |
  15. +--------------------+
  16. 1 row in set (0.00 sec)
  17. mysql> create database meitu charset=utf8;
  18. ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'meitu'

解决方法:

1. 在/etc/my.cnf的[mysqld]字段下加入:skip-grant-tables , 如下截图

mysql 建库报匿名用户权限错误

2. 再重启mysqld服务
[maaiqiang@localhost ~]$ systemctl restart mysqld

这时的mysql不需要密码即可登录数据库

3. 登录进入mysql,执行以下命令
  1. mysql > use mysql;
  2. mysql > delete from user where USER='';
  3. mysql > flush privileges;
  4. mysql > exit;
4. 再删除/etc/my.ini中的skip-grant-tables,重启mysqld服务即可正常建库了。
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/985272?site
推荐阅读
相关标签
  

闽ICP备14008679号