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