26

I have tried query but there is an error.
Does anybody solved the error?

MariaDB [mysql]> UPDATE user SET Host='%' WHERE User='root'; 
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 Answer 1

55

MariaDB-10.4+ the mysql.user is a view rather than a table.

Its recommend to stop copying off old blogs to do any authentication relates changes in MySQL and MariaDB, the mechanisms are being updated and no longer apply. Always check the official documentation.

Use SET PASSWORD or ALTER USER to manage user authentication.

Also modifying a user/host component of the username will put triggers, events, plugins, grants, roles etc out of sync with the combined username (aka broken). So just DROP/CREATE users rather than manipulate them.

6
  • 1
    I'm facing this issue now I suppose. I copied all the old Wordpress databases that were created with older version of MariaDB (via mysqldump and then restore via source). I suppose now the old users don't have access to the databases. How should I now enable all the old users to have access to the right database? Even I log in as root, and issue the command: SELECT user FROM mysql.user; it gives the above error. What is the solution?
    – PKHunter
    Jan 3, 2021 at 20:24
  • @PKHunter please ask this as a new question and include details like the source and destination version.
    – danblack
    Jan 3, 2021 at 23:49
  • @danblack the real mvp! We recently upgraded from MariaDB 10.3. Didn't thought about that the mechanism could change and used the old one as I always did. Should've known better, Thanks a lot!
    – flokoe
    Mar 24, 2021 at 9:43
  • I should have mentioned RENAME USER too.
    – danblack
    Jun 1, 2021 at 23:26
  • 5
    You can do RENAME USER "root"@"localhost" TO "root"@"%"; Oct 31, 2022 at 6:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.