Symptoms
The following database error happens when attempting to create or restore a database:
View 'mysql.user' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
Description
This issue is caused by the maridb.sys user not having the correct privileges. You can verify this by running the following command, which should reproduce the error:
mysql mysql -e 'select * from user;'
Workaround
- Backup the existing mysql database by running the following command:
mysqldump mysql > /root/mysql.sql
- Access the mysql database via the mysql CLI:
mysql mysql
- Run the following query:
INSERT INTO `tables_priv` (`Host`, `Db`, `User`, `Table_name`, `Grantor`, `Timestamp`, `Table_priv`, `Column_priv`) VALUES ('localhost','mysql','mariadb.sys','global_priv','root@localhost','0000-00-00 00:00:00','Select,Delete',''); - Restart the service:
/scripts/restartsrv_mysql