2

我像往常一样设置了数据库和用户以及授予权限,但我仍然被拒绝访问,我不知道为什么:

[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)
4

2 回答 2

2

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

授予所有特权 redditonrails_developmentlocalhost

db-level GRANT 的预期语法是: ON $db.$table. 基于此,您只授予名为“localhost”的表。改成:

授予所有权限 redditonrails_development.*

于 2011-05-18T16:39:11.967 回答
1

您的用户 redditonrails 似乎拥有所有特权 redditonrails_developmentlocalhost

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

redditonrails_development.*

女巫意味着您在所有表上都拥有所有特权(甚至是您尝试创建的新表)

或者至少我是这么看的。

于 2011-05-18T16:41:16.290 回答