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


你有没有尝试过这样的事情,

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'
链接地址: http://www.djcxy.com/p/69272.html

上一篇: 如何授予管理员的所有撤销权限

下一篇: 如何在没有mysql的数据库上授予数据库特权?