MariaDB使用mysql.user時Insert操作報錯:ERROR 1356 (HY000): View 'mysql.user' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them


報錯1:創建用戶或者更新用戶信息報錯

MariaDB [mysql]> INSERT INTO user SET Host='%', User='test';
ERROR 1356 (HY000): View 'mysql.user' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them

解決方法:

更新:

MariaDB [mysql]> SET PASSWORD FOR 'test'@'localhost' = PASSWORD('123456qwer');
Query OK, 0 rows affected (0.006 sec)

插入:

MariaDB [mysql]> create user 'test'@'%' identified by 'YisaOmni@2021$%';
Query OK, 0 rows affected (0.006 sec)

 

報錯2:用戶賦權報錯

MariaDB [(none)]> INSERT INTO mysql.user (Host, Db, User, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Grant_priv, References_priv, Index_priv, Alter_priv, Create_tmp_table_priv, Lock_tables_priv, Create_view_priv, Show_view_priv, Create_routine_priv, Alter_routine_priv, Execute_priv, Event_priv, Trigger_priv) VALUES ('%', 'test_db', 'test', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y');
ERROR 1356 (HY000): View 'mysql.user' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
MariaDB [(none)]>

解決:

MariaDB [(none)]> grant all privileges on *.* to 'test'@'%' identified by '123456qwer';
Query OK, 0 rows affected (0.005 sec)

MariaDB [(none)]> delete from mysql.user where User='';
Query OK, 2 rows affected (0.006 sec)

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)

問題原因:MariaDB-10.4+mysql.user是一個視圖而不是一個表。有以上操作的話可以直接刪除、重建。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM