我正在x86_64(MySQL社区服务器-GPL)上运行用于Linux的MySQL服务器8.0.18版。 尽管用户拥有所有必需的权限,但无法创建数据库;
create database meta_info;
ERROR 1044 (42000): Access denied for user 'user1'@'localhost' to database 'meta_info'
我获取了权限,用户似乎拥有所有权限,例如root。
show grants for 'user1'@'localhost';
+------------------------------------------------+
| Grants for user1@localhost |
+------------------------------------------------+
| GRANT USAGE ON *.* TO `user1`@`localhost` |
+------------------------------------------------+
1 row in set (0.00 sec)
SHOW GRANTS for 'user1'@'%';
---------------------------------------------------------------------------------------+
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `user1`@`%` WITH GRANT OPTION |
| GRANT APPLICATION_PASSWORD_ADMIN,AUDIT_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CLONE_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,GROUP_REPLICATION_ADMIN,INNODB_REDO_LOG_ARCHIVE,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON *.* TO `user1`@`%` WITH GRANT OPTION |
是否缺少任何权限?
答案 0 :(得分:0)
更改权限后是否运行了“ FLUSH PRIVILEGES
”?否则,更改将不受影响。
答案 1 :(得分:0)
找到了问题。管理员两次授予了“ user1”访问权限,一次是“ user1” @“ localhost”,另一次是“ user1'@'%'。在第一种情况下,它没有所有权限,而在第二种情况下有。所以我做了DROP USER 'user1'@'localhost'
,它解决了错误。
但是,我不确定在show grants
从'%'行读取时,为什么mysql服务器会引用'localhost'条目的权限。