how to grant privileges on a database without table in mysql?
I was wondering how to grant privileges on a database without table.
I've 开发者_Python百科tried the following:
GRANT ALL ON databasename to username@hostname;
and it shows me an error saying "can't find any matching row in the user table".
Have you tried something of this sort,
mysql> create database amarokdb;
Query OK, 1 row affected (0.00 sec)
mysql> grant usage on *.* to amarokuser@localhost identified by 'amarokpasswd';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on amarokdb.* to amarokuser@localhost ;
Query OK, 0 rows affected (0.00 sec)
It is likely that your server has the NO_AUTO_CREATE_USER mode enabled.
From the MySQL manual: (http://dev.mysql.com/doc/refman/5.6/en/server-sql-mode.html)
NO_AUTO_CREATE_USER prevents the GRANT statement from automatically creating new users if it would otherwise do so, unless a nonempty password also is specified. (Added in MySQL 5.0.2)
So you can either remove the NO_AUTO_CREATE_USER mode or create the user WITH a password like this:
GRANT ALL ON databasename TO username@hostname IDENTIFIED BY 'your non-empty password here'
精彩评论