欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > 数据库 >内容正文

数据库

mysql建库需要权限吗_mysql 建库报匿名用户权限错误

发布时间:2025/3/15 数据库 32 豆豆
生活随笔 收集整理的这篇文章主要介绍了 mysql建库需要权限吗_mysql 建库报匿名用户权限错误 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

ERROR 1044 (42000): Access denied for user [email protected] to database ‘meitu‘

系统环境:

Centos 7.5

Mysql Server version: 5.6.48

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

问题描述:

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

[[email protected] 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 [email protected] to database ‘meitu‘

解决方法:

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

2. 再重启mysqld服务

[[email protected] ~]$ 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服务即可正常建库了。

原文:https://blog.51cto.com/10316297/2496822

总结

以上是生活随笔为你收集整理的mysql建库需要权限吗_mysql 建库报匿名用户权限错误的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。