Reading the mysql.user view fails with error 1356
Queries on the mysql.user view fail because the server considers the view invalid (error 1356)Short answer
Since MariaDB 10.4, mysql.user is only a compatibility view over mysql.global_priv. Error 1356 means that view cannot run against the tables under it, which happens when the system tables come from another version or from MySQL. Back up, then run mariadb-upgrade so the mysql schema matches the server binary.
Fix it fast
1Find out which cause you have
Ask the server who owns the view and what it selects from. The definer and the underlying table tell you whether the mysql schema is the right version.
SHOW CREATE VIEW mysql.user\G SELECT VERSION();2Match what you see, then jump to its fix
What does the error look like?
Queries on the mysql.user view fail because the server considers the view invalid (error 1356)
Cause 1 of 2
The mysql system tables are older than the server
1Check
The server logs a recommendation to upgrade when the system tables are older. Read the startup lines of the error log.
sudo journalctl -u mariadb.service | grep -i upgrade2Fix
Take a full backup, then run mariadb-upgrade. It updates the system tables, recreates missing mysql tables and checks the others. The mysql_upgrade name still works.
sudo mariadb-dump --all-databases > all-databases.sql
sudo mariadb-upgrade3Verify
The view can be read again.
SELECT user, host FROM mysql.user LIMIT 3;Confirmed by mariadb.com
Cause 2 of 2
The data directory came from MySQL
1Check
MariaDB keeps account data in mysql.global_priv and exposes mysql.user as a view over it. A MySQL data directory has a real mysql.user table instead.
SHOW TABLES FROM mysql LIKE 'global_priv';2Fix
After migrating from MySQL, run mariadb-upgrade. Do it on a copy first, and prefer a logical dump and restore when moving between the two products.
sudo mariadb-upgrade3Verify
mysql.global_priv exists and the view works.
SHOW TABLES FROM mysql LIKE 'global_priv';
SELECT COUNT(*) FROM mysql.user;Confirmed by mariadb.com
How do I stop it coming back?
- Run mariadb-upgrade after every major upgrade on systems that do not run it for you (Debian and Ubuntu packages do).
- Read accounts through information_schema or SHOW GRANTS, not by editing mysql.user; use GRANT and CREATE USER.
- Back up all databases before any version change.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- ShopGoAn e-commerce aggregator with a Python scraping engine behind its catalog, past 10K Google Play downloads.
Related fixes
Databases
Installing the Airflow MySQL provider fails on pkg-config or mysqlclient
Building the mysqlclient wheel fails during the install
The Airflow MySQL provider depends on mysqlclient, which pip compiles against the MySQL C client library.
2 causes, each with a fixDatabases
A query on Aurora MySQL dies with 'table /rdsdbdata/tmp/#sql... is full'
ERROR 1114 (HY000): The table '/rdsdbdata/tmp/#sqlfd_1586_2' is full
In Aurora MySQL 3, internal temporary tables share one pool, and when that pool and the memory-mapped overflow file are used up, a reader instance ends the query with error 1114.
3 causes, each with a fixDatabases
Azure Database for MySQL refuses a connection that does not use SSL
ERROR 3159 (HY000): Connections using insecure transport are prohibited while --require_secure_transport=ON.
Azure Database for MySQL Flexible Server requires encrypted connections by default (require_secure_transport = ON, TLS 1.2).
4 causes, each with a fixDatabases
Compiling a C or C++ program that includes mysql.h fails
undefined reference to `mysql_init'
The compiler only finds mysql.h when the MySQL client development files are installed and their folder is on the include path.
3 causes, each with a fixDatabases
DBeaver fails to resolve Maven dependencies when downloading a database driver
A driver library does not download automatically
DBeaver downloads driver jars from a Maven repository.
3 causes, each with a fixDatabases
DBeaver cannot verify the MySQL server certificate
unable to find valid certification path to requested target
DBeaver's MySQL driver is checking the server certificate and Java does not trust the CA that signed it.
2 causes, each with a fix