Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem that grant is not effective under MySQL

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to solve the problem that grant does not take effect under MySQL". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to solve the problem that grant does not take effect under MySQL.

Recently, everyone's enthusiasm for learning is very high, and one of the netizens in the group encountered a problem. The database is set to "grant all privileges on. To 'root'@'%' identified by' password' with grant option;". Why can't I see the library when I log in remotely?

There is a picture and a truth, and the operation of this wave seems to be similar. In theory, after the grant command is executed, there is no need to follow the flush privileges command. Because grant statements take effect immediately.

That is, after grant, both db and memory are updated, and they are synchronized. But the reality is that after we execute the following statement, we log in remotely and still can't see the library.

In fact, this is an important point of knowledge forgotten by the progressive students. That is:

The grant command updates both disk and memory for global permissions. The command takes effect immediately after completion, and the newly created connection uses the new permissions.

For an existing connection, its global permissions are not affected by the grant command.

When I saw it, I asked him immediately. Whether the old connection does not have permission, the new connection is OK.

Sure enough, he replied to me, yes. But what about existing connections?

He came up with another trick to restart the MySQL service.

That's a tough move. He picked up the kill move of restarting in the programmer world. However, the restart failed, and after the restart, the existing connection still does not have permission. The specific manifestation is that the replication connection on the slave library is still not authorized.

This illustrates a problem, restart MySQL, the permissions in memory are not refreshed.

What are we going to do? One way is for kill to drop an existing connection. The other is to actively disconnect and reconnect again. For example, stop the slave on the repository and re-establish the connection.

When the connection is re-established, permission verification is performed again. In this way, the permissions of the new changes can take effect.

Some people may wonder why the MySQL service is restarted, but it still doesn't work. This is because there is no logic to synchronize permissions on memory and disk when you restart the MySQL service. But when you restart the MySQL service, the MySQL configuration file is reloaded, which is for sure.

My chapter 46 is not perfect. Access to a lot of information, but also did not see the restart of the MySQL service, what on earth have you done? In this chapter, I hope Dinky can eat more! Tell us about the restart of MySQL!

Thank you for your reading, the above is the content of "how to solve the problem of invalid grant under MySQL". After the study of this article, I believe you have a deeper understanding of how to solve the problem of invalid grant under MySQL, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report