In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly shows you "how to use grant and revoke in MySQL". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to use grant and revoke in MySQL".
The simple format of the command granted by MySQL to the user can be summarized as follows:
Grant permissions on database object to user
Grant ordinary data users have the right to query, insert, update and delete all table data in the database
Grant select on testdb.* to common_user@'%'
Grant insert on testdb.* to common_user@'%'
Grant update on testdb.* to common_user@'%'
Grant delete on testdb.* to common_user@'%'
Or, replace it with a MySQL command:
Grant select, insert, update, delete on testdb.* to common_user@'%'
Second, grant database developers, create tables, indexes, views, stored procedures, functions and other permissions
Grant creates, modifies, and deletes MySQL data table structure permissions.
Grant create on testdb.* to developer@'192.168.0.%'
Grant alter on testdb.* to developer@'192.168.0.%'
Grant drop on testdb.* to developer@'192.168.0.%'
Grant operation MySQL foreign key permissions:
Grant references on testdb.* to developer@'192.168.0.%'
Permissions for grant to manipulate MySQL temporary table:
Grant create temporary tables on testdb.* to developer@'192.168.0.%'
Grant operation MySQL index permissions:
Grant index on testdb.* to developer@'192.168.0.%'
Grant manipulates MySQL view, view view source code permissions:
Grant create view on testdb.* to developer@'192.168.0.%'
Grant show view on testdb.* to developer@'192.168.0.%'
Grant manipulates MySQL stored procedures and function permissions:
Grant create routine on testdb.* to developer@'192.168.0.%';-- now, can show procedure status
Grant alter routine on testdb.* to developer@'192.168.0.%';-- now, you can drop a procedure
Grant execute on testdb.* to developer@'192.168.0.%'
3. The right of grant ordinary DBA to manage a certain MySQL database
Grant all privileges on testdb to dba@'localhost'
The keyword "privileges" can be omitted.
4. Grant Advanced DBA manages the permissions of all databases in MySQL:
Grant all on *. * to dba@'localhost'
5. MySQL grant permissions, which can be used at multiple levels.
1. Grant acts on the entire MySQL server:
Grant select on *. * to dba@localhost;-- dba can query tables in all databases in MySQL.
Grant all on *. * to dba@localhost;-- dba can manage all databases in MySQL
2. Grant acts on a single database:
Grant select on testdb.* to dba@localhost;-- dba can query tables in testdb.
3. Grant acts on a single data table:
Grant select, insert, update, delete on testdb.orders to dba@localhost
Here, when authorizing multiple tables to a user, the above statements can be executed multiple times. For example:
Grant select (user_id,username) on smp.users to mo_user@'%' identified by '123345'
Grant select on smp.mo_sms to mo_user@'%' identified by '123345'
4. Grant acts on the columns in the table:
Grant select (id, se, rank) on testdb.apache_log to dba@localhost
5. Grant acts on stored procedures and functions:
Grant execute on procedure testdb.pr_add to 'dba'@'localhost'
Grant execute on function testdb.fn_add to 'dba'@'localhost'
6. View MySQL user permissions
View current user (own) permissions:
Show grants
View additional MySQL user rights:
Show grants for dba@localhost
Revoke the permissions that have been granted to MySQL users.
The syntax of revoke is similar to that of grant, except that you can replace the keyword "to" with "from":
Grant all on *. * to dba@localhost
Revoke all on *. * from dba@localhost
VIII. Considerations for user rights of MySQL grant and revoke
1. After the grant, revoke user permission, the user will not take effect until the user reconnects to the MySQL database.
two。 If you want authorized users, you can also grant these permissions to other users. You need the option "grant option".
Grant select on testdb.* to dba@localhost with grant option
This feature is generally not needed. In practice, database permissions are best managed by DBA.
The above is all the contents of the article "how to use grant and revoke in MySQL". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.