Bug #17564 RENAME DATABASE doesn't change user privileges
Submitted: 20 Feb 2006 2:43 Modified: 20 Feb 2006 11:29
Reporter: Markus Popp Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.1.8BK OS:Linux (SuSE Linux 10.0)
Assigned to: CPU Architecture:Any

[20 Feb 2006 2:43] Markus Popp
Description:
If you rename a database with the new RENAME DATABASE command, the privileges remain unchanged.

How to repeat:
mysql> create user user@localhost;
Query OK, 0 rows affected (0.00 sec)

mysql> grant all on test2.* to user@localhost;
Query OK, 0 rows affected (0.00 sec)

mysql> rename database test2 to test;
Query OK, 0 rows affected (0.01 sec)

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select Host, User, Db from db;
+-----------+------+-------+
| Host      | User | Db    |
+-----------+------+-------+
| localhost | user | test2 |
+-----------+------+-------+
1 row in set (0.00 sec)

mysql>

Suggested fix:
RENAME DATABASE should also change the database information in the privilege tables.
[20 Feb 2006 4:17] Paul DuBois
The reported behavior is as documented:

http://dev.mysql.com/doc/refman/5.1/en/rename-database.html

Analogously, RENAME TABLE changes no privileges, either.
[20 Feb 2006 11:29] MySQL Verification Team
Expected behavior how Paul commented it.