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

编程入门 行业动态 更新时间:2024-10-26 07:40:41

mysql给用户授权的时候遇到个报错

mysql> grant select on INFORMATION_SCHEMA.TABLE_PRIVILEGES to usr_r@'192.168.11.11';
ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'information_schema'

在mos找到一篇文档解释

Why Setting Privileges on INFORMATION_SCHEMA does not Work (文档 ID 1941558.1)

APPLIES TO:

MySQL Server - Version 5.6 and later
Information in this document applies to any platform.

GOAL

To determine how MySQL privileges work for INFORMATION_SCHEMA.
 

SOLUTION

A simple GRANT statement would be something like:

mysql> grant select,execute on information_schema.* to 'dbadm'@'localhost';
ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'information_schema'


The error indicates that the super user does not have the privileges to change the information_schema access privileges.
Which seems to go against what is normally the case for the root account which has SUPER privileges.

The reason for this error is that the information_schema database is actually a virtual database that is built when the service is started.
It is made up of tables and views designed to keep track of the server meta-data, that is, details of all the tables, procedures etc. in the database server.
So looking specifically at the above command, there is an attempt to add SELECT and EXECUTE privileges to this specialised database.

The SELECT option is not required however, because all users have the ability to read the tables in the information_schema database, so this is redundant.(所以这个权限根本不用授就有了)

The EXECUTE option does not make sense, because you are not allowed to create procedures in this special database.

There is also no capability to modify the tables in terms of INSERT, UPDATE, DELETE etc., so privileges are hard coded instead of managed per user.

更多推荐

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

本文发布于:2023-06-14 03:42:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1434094.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Access   denied   ERROR   database   information_schema

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!