MySQL Grant command

Source: Internet
Author: User
Tags dba

Permission to change or delete the search
Grant Select on testdb.* to [email protected] '% 'Grant Insert on TestDB. * to [email protected] '% 'Grant Update on TestDB. * to [email protected] '% 'Grant Delete on TestDB. * to [email protected] '% '
Grant SELECT, INSERT, UPDATE, delete on testdb.* to [email protected] '% '
all permissions where the keyword "privileges" can be omitted. Grant all privileges on database_name. * to [e-mail protected] identified by "000000";

Grant Advanced DBA manages permissions for all databases in MySQL.
Grant all on * * to [email protected] ' localhost '


Create modify, delete permissions for table
Grant create on testdb.* to [email protected] ' 192.168.0.% ';
Grant ALTER on testdb.* to [email protected] ' 192.168.0.% ';
Grant drop on testdb.* to [email protected] ' 192.168.0.% ';

Foreign key Operation permissions
Grant references on testdb.* to [email protected] ' 192.168.0.% ';

Temporary table permissions
Grant create temporary tables on testdb.* to [email protected] ' 192.168.0.% ';

Index permissions
Grant index on testdb.* to [email protected] ' 192.168.0.% ';

Grant acts on stored procedures, functions:

Grant execute on procedure testdb.pr_add to ' dba ' @ ' localhost '
Grant execute on function testdb.fn_add to ' dba ' @ ' localhost '

Grant action on a column in a table
Grant Select (ID, SE, rank) on testdb.apache_log to [email protected];
Grant functions can be divided into multiple levels
1.grant on the entire MySQL server
Grant SELECT On *. * to [email protected]; --DBAs can query tables in all databases in MySQL.
Grant all on * * to [email protected];--DBA can manage all databases in MySQL
2.grant Single Library
Grant all on test.* to [email protected];
3.grant Single Table
Grant all on test.tb1 to [email protected];
4.grant Multiple columns
Grant Select (id,name) on test.tb1 to [email protected]
5.grant stored procedures, functions
Grant execute on procedure testdb.pr_add to ' dba ' @ ' localhost '
Grant execute on function testdb.fn_add to ' dba ' @ ' localhost '


To view the current user (own) permissions:

Show grants;

To view additional MySQL user rights:

Show grants for [email protected];

REVOKE permission replace with revoke to the From

MySQL Grant command

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.