Privilege to set default database in MySQL It turns out that a user cannot set default database if it does not have global (mysql.user) or any database-level permissions (mysql.db):

MariaDB [(none)]&gt; use mysql;
ERROR 1044 (42000): Access denied for user 'XXX'@'%' to database 'mysql'


However, using default database could be convenient, e. i. there is a lot old scripts relying on that.

The only workaround I've found so far, is to grant SHOW VIEW on the database: I do not want to grant even read-only access for all tables.

What do I miss? I don't know any SQL syntax that allows insert 'N' in all relevant columns in mysql.db, and don't want to do it with raw SQL (INSERT ...).
Well, thanks Rick James, it is a bit more complicated. The problem is with MariaDB.

Update: https://jira.mariadb.org/browse/MDEV-9614