我正在创建一个专门用于django项目的新用户,我用mariadb和phpmyadmin做了这个用户,完成了,尝试用mysql做同样的事情,突然我发现我的root用户不能授予特权给其他用户。
还有,我尝试了我的第二个超级用户admin,他们都无法授予它,我已经尝试过几种解决此问题的方法,这些问题在stackoverflow中发布,但没有任何效果。
这不是远程连接,来自localhost的所有内容。
看到很多人说我应该在授予选项后刷新特权,问题是我一开始就无法授予任何权限,已经尝试使用admin将所有具有Grant选项的权限授予root,反之亦然
当前行准确显示了您的期望,admin和root都具有grant和super priv。
第二行显示了root用户拥有和授予的所有特权,如您所见,最后一行显示了Grant选项。
SELECT Host,User,Grant_priv,Super_priv FROM mysql.user;
SHOW GRANTS FOR 'root'@'localhost';
╔═══════════╦══════════════════╦════════════╦════════════╗
║ Host ║ User ║ Grant_priv ║ Super_priv ║
╠═══════════╬══════════════════╬════════════╬════════════╣
║ % ║ admin ║ Y ║ Y ║
║ % ║ gameled_admin ║ N ║ N ║
║ localhost ║ mysql.infoschema ║ N ║ N ║
║ localhost ║ mysql.session ║ N ║ Y ║
║ localhost ║ mysql.sys ║ N ║ N ║
║ localhost ║ root ║ Y ║ Y ║
╚═══════════╩══════════════════╩════════════╩════════════╝
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 `root`@`localhost` WITH GRANT OPTION
GRANT BACKUP_ADMIN,BINLOG_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,GROUP_REPLICATION_ADMIN,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SET_USER_ID,SYSTEM_VARIABLES_ADMIN,XA_RECOVER_ADMIN ON *.* TO `root`@`localhost` WITH GRANT OPTION
GRANT ALL PRIVILEGES ON `mysql`.* TO `root`@`localhost` WITH GRANT OPTION
GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION
任何事情都会有所帮助,在此先感谢
编辑1:
另一个经过测试的代码:
SELECT User()
结果:
╔════════════════╗
║ User() ║
╠════════════════╣
║ root@localhost ║
╚════════════════╝
我得到的一些错误是:
You are not allowed to create a user with GRANT
我用这行
SHOW GRANTS FOR 'multilang_user';
并得到这个:
There is no such grant defined for user 'multilang_user' on host '%'
编辑2:
已创建一个新的'root'@'%'用户
SHOW GRANTS FOR 'root'@'%';
此行再次显示:
Grants for root@%
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 `root`@`%` WITH GRANT OPTION
GRANT BACKUP_ADMIN,BINLOG_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,GROUP_REPLICATION_ADMIN,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SET_USER_ID,SYSTEM_VARIABLES_ADMIN,XA_RECOVER_ADMIN ON *.* TO `root`@`%` WITH GRANT OPTION
再次测试:
GRANT ALL ON *.* TO 'multilang_user'@'localhost' WITH GRANT OPTION;
并得出以下结果:
You are not allowed to create a user with GRANT
解决了3个问题:
解决方案:所以我决定删除我的多语言用户并再次创建它,这次在用户名的末尾指定@'localhost',这样我就可以从root @ localhost授予所有特权>