MySQL GRANT 已被接受但未应用

MySQL GRANT is accepted but not applied

我很困惑。我正在我的开发服务器上创建一个数据库,并为该数据库创建一个用户。我已经这样做了一百万次,但现在我在 MySql 8 工作。这是我正在尝试的:

$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Server version: 8.0.27-0ubuntu0.20.04.1 (Ubuntu)

mysql> GRANT ALL PRIVILEGES ON * . * TO 'zak'@'localhost';
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

$ mysql -u zak -p
Welcome to the MySQL monitor.  Commands end with ; or \g.
Server version: 8.0.27-0ubuntu0.20.04.1 (Ubuntu)

mysql> GRANT ALL PRIVILEGES ON wp_zakattack . * TO 'adm_zakattack'@'localhost';
ERROR 1044 (42000): Access denied for user 'zak'@'localhost' to database 'wp_zakattack'
mysql> show grants;
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for zak@localhost                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 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 `zak`@`localhost`                                                                                                                                                                                                                                                                                                 |
| GRANT APPLICATION_PASSWORD_ADMIN,AUDIT_ADMIN,AUTHENTICATION_POLICY_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CLONE_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,FLUSH_OPTIMIZER_COSTS,FLUSH_STATUS,FLUSH_TABLES,FLUSH_USER_RESOURCES,GROUP_REPLICATION_ADMIN,GROUP_REPLICATION_STREAM,INNODB_REDO_LOG_ARCHIVE,INNODB_REDO_LOG_ENABLE,PASSWORDLESS_USER_ADMIN,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,SHOW_ROUTINE,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON *.* TO `zak`@`localhost` |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

我知道我可以像 root 一样轻松地做到这一点。但是当它投入生产时,我禁用了 root 用户,并且这些操作由使用配置编辑器的 bash 脚本处理无密码登录。 IE mysql --login-path=data-main 所以我需要用户 'zak'@'localhost' 才能 GRANT 到特定的用户和表。有没有什么明显的东西是我想念的?

您没有授予zak授予权限的权限。这不包括在 ALL PRIVILEGES.

mysql> GRANT ALL PRIVILEGES ON *.* TO 'zak'@'localhost' WITH GRANT OPTION;
Query OK, 0 rows affected (0.01 sec)