MySQL:授予 CREATE 权限被拒绝

发布于 2024-11-07 21:46:52 字数 1701 浏览 2 评论 0原文

我设置了一个数据库&用户以及我通常所做的授予权限,但我仍然被拒绝访问,我不知道为什么:

[root@server23 redditonrails]# mysql -u redditonrails -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 431954
Server version: 5.0.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use redditonrails_development;
Database changed
mysql> create table test;
ERROR 1142 (42000): CREATE command denied to user 'redditonrails'@'localhost' for table 'test'
mysql> show grants;
+------------------------------------------------------------------------------------------------+
| Grants for redditonrails@localhost                                                             |
+------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'redditonrails'@'localhost' IDENTIFIED BY PASSWORD '*******'    |
| GRANT ALL PRIVILEGES ON `redditonrails_test`.`localhost` TO 'redditonrails'@'localhost'        |
| GRANT ALL PRIVILEGES ON `redditonrails_development`.`localhost` TO 'redditonrails'@'localhost' |
| GRANT ALL PRIVILEGES ON `redditonrails`.`localhost` TO 'redditonrails'@'localhost'             |
+------------------------------------------------------------------------------------------------+
4 rows in set (0.00 sec)

mysql> SELECT USER(),CURRENT_USER();
+-------------------------+-------------------------+
| USER()                  | CURRENT_USER()          |
+-------------------------+-------------------------+
| redditonrails@localhost | redditonrails@localhost |
+-------------------------+-------------------------+
1 row in set (0.00 sec)

I setup a database & user along with grant permissions how I normally do and I'm still getting access denied and I'm not sure why:

[root@server23 redditonrails]# mysql -u redditonrails -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 431954
Server version: 5.0.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use redditonrails_development;
Database changed
mysql> create table test;
ERROR 1142 (42000): CREATE command denied to user 'redditonrails'@'localhost' for table 'test'
mysql> show grants;
+------------------------------------------------------------------------------------------------+
| Grants for redditonrails@localhost                                                             |
+------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'redditonrails'@'localhost' IDENTIFIED BY PASSWORD '*******'    |
| GRANT ALL PRIVILEGES ON `redditonrails_test`.`localhost` TO 'redditonrails'@'localhost'        |
| GRANT ALL PRIVILEGES ON `redditonrails_development`.`localhost` TO 'redditonrails'@'localhost' |
| GRANT ALL PRIVILEGES ON `redditonrails`.`localhost` TO 'redditonrails'@'localhost'             |
+------------------------------------------------------------------------------------------------+
4 rows in set (0.00 sec)

mysql> SELECT USER(),CURRENT_USER();
+-------------------------+-------------------------+
| USER()                  | CURRENT_USER()          |
+-------------------------+-------------------------+
| redditonrails@localhost | redditonrails@localhost |
+-------------------------+-------------------------+
1 row in set (0.00 sec)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

千柳 2024-11-14 21:46:52

我不相信你的语法是正确的。您指定:

授予所有权限
redditonrails_development.localhost

数据库级 GRANT 的预期语法为:ON $db.$table。基于此,您仅授予名为“localhost”的表。更改为:

授予所有权限
redditonrails_development.*

I don't believe your syntax is right. You're specifying:

GRANT ALL PRIVILEGES ON
redditonrails_development.localhost

The expected syntax for db-level GRANT is: ON $db.$table. Based on this, you're only granting on the table named "localhost". Change to:

GRANT ALL PRIVILEGES ON
redditonrails_development.*

笨死的猪 2024-11-14 21:46:52

您的用户 redditonrails 似乎拥有所有权限
redditonrails_development.localhost

这意味着 redditonrails_development 数据库和 localhost 表。你想要的是那里

redditonrails_development.*

女巫意味着你拥有所有表的所有特权(甚至是你试图创建的新表)

,或者至少是这样我怎么看。

It would seem that your user redditonrails has all privilages on
redditonrails_development.localhost

which would mean redditonrails_development database and localhost table. what you want is to have there

redditonrails_development.*

witch would mean you have all privilages on all tables (even the new ones you're trying to create)

or at least that's how I see it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文