Bug #46231 Set default database by user login
Submitted: 16 Jul 2009 15:48
Reporter: Scott Noyes Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S4 (Feature request)
Version: OS:Any
Assigned to: CPU Architecture:Any

[16 Jul 2009 15:48] Scott Noyes
Description:
Sybase provides a default database for each user, which is set automatically on login. Provide similar functionality for MySQL.

How to repeat:
mysql -u userName
SELECT DATABASE(); -- should automatically be set to default database for the given userName

Suggested fix:
If the USE statement were allowed in prepared statements, then we could write this into an init-connect statement.

Or, DATABASE() could accept a parameter that would set the current database to the given parameter.

Or, the privilege system could be extended to include a default database for each user in the mysql.user table.