문제

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)
도움이 되었습니까?

해결책

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.*

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top