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

报错信息:

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

系统环境:

Centos 7.5

Mysql Server version: 5.6.48

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

问题描述:

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

[root@localhost mysql]# mysql -uroot

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.6.48 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

+--------------------+

1 row in set (0.00 sec)

mysql> create database meitu charset=utf8;

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

解决方法:

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

dc13a72eef03c8bb3bde52b189f0f46a.png

2. 再重启mysqld服务

[maaiqiang@localhost ~]$ systemctl restart mysqld

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

3. 登录进入mysql,执行以下命令

mysql > use mysql;

mysql > delete from user where USER='';

mysql > flush privileges;

mysql > exit;

4. 再删除/etc/my.ini中的skip-grant-tables,重启mysqld服务即可正常建库了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值