Get the App
SLTechnology News&Howtos  ›  Database  › 

Root users of mysql cannot authorize ordinary users to deal with the problem.

Shulou Source: shulou.com Published: 2022-06-01 06:34:44 10月04日 Update

Let's first look at the error phenomenon:

Oddly enough, it should be impossible for root users to authorize ordinary users. The hint seems to say the password is wrong. But actually there's nothing wrong with the password.

Decided to see what the permissions of the user root@localhost are in the mysql.user table. Globally related permission information is recorded in the mysql.user table. This global permission does not mean having all permissions, it specifically refers to having permissions for all database objects on the MYSQL server.

Mysql > select * from mysql.user where User='root' and Host='localhost'\ G

You can see that Grant_priv is N. Obviously, because the user root@localhost does not have permission to grant permissions, the previous operation reported an error. Change the value of Grant_priv to Y, refresh it, then log out and log back in. The problem is solved.

Mysql > update mysql.user set Grant_priv='Y' where User='root' and Host='localhost'

Mysql > flush privileges

Conclusion: this problem is not very common. But this problem provides a way to solve the problem, how to start when there is a problem with the authority. The granularity of permissions in mysql is global, database, table, column and program from coarse to fine. It can be summed up in one sentence: assign permission for a user to connect from a machine to access a part of a record in a column of a table under a database. The globally relevant permission information is recorded in the mysql.user table. The permission information at the record database level is the mysql.db table. The authorization information record for the record table object is in the mysql.tables_ private table. Column-level permissions are recorded in the mysql.column_ private table.

Tags: Permissions users questions information global data databases passwords objects errors ordinary in a word actually in fact common ideas servers machines phenomena Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Information MariaDB Xiaomi Apple