In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to use the MySQL authorization command grant". In the daily operation, I believe many people have doubts about how to use the MySQL authorization command grant. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to use the MySQL authorization command grant". Next, please follow the editor to study!
How to use the MySQL authorization command grant:
This article is an example, running on MySQL version 5.0 and above.
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@'%' II, grant database developers, create tables, indexes, views, stored procedures, functions. Wait for permission.
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 manipulates MySQL foreign key permissions.
Grant references on testdb.* to developer@'192.168.0.%'
Grant manipulates MySQL temporary table permissions.
Grant create temporary tables on testdb.* to developer@'192.168.0.%'
Grant manipulates MySQL index permissions.
Grant index on testdb.* to developer@'192.168.0.%'
Grant manipulates MySQL view and 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 statusgrant alter routine on testdb.* to developer@'192.168.0.%';-- now, you can drop a proceduregrant execute on testdb.* to developer@'192.168.0.%'; III, grant the permission of an ordinary DBA to manage a 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' V and MySQL grant permissions can be used at multiple levels, respectively.
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' VI. View MySQL user permissions
View current user (own) permissions:
Show grants
View additional MySQL user rights:
Show grants for dba@localhost; 7. 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, MySQL grant, revoke user rights considerations
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.
At this point, the study on "how to use the MySQL authorization command grant" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.