Tag Archives: ERROR 1044 (42000): Access denied for user ‘root’@’localhost’ to database ‘in…

ERROR 1044 (42000): Access denied for user ‘root’@’localhost’ to database ‘in…

We are dealing with this problem( https://www.cnblogs.com/abclife/p/11038660.html )The developer encountered the following error message when modifying the definer of the view at last:

ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'information_schema'

 

The database version is MySQL 5.7.25. Ask him to do the following:

>select user();
>select current_user() from dual;
>select host,user from mysql.user where user='root';

>show grants for root@'localhost';
>show grants for root@'%';

>select * from mysql.user where user='root';

  

The feedback said that there was nothing wrong with the user and the permission, and then asked the user to send the screenshot of the execution error again

root@localhost:information_schema 11:16:24>alter definer=`root`@`%` view <view_name> as select  ...
ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'information_schema'

 

As you can see, it’s in information_ Schema database, switch to the database where the view is located, and execute the command again to execute correctly

Because of information_ Schema is a virtual database in which all tables are views. In fact, when importing data, there is no need to import information_ Schema.