MySQL Account management and authorization

Source: Internet
Author: User

Username: ' User ' @ ' host '

Creation format: Create USER ' username ' @ ' host ' [identified by ' Password ']

mysql> create user ' test ' @ '% ';

Query OK, 0 rows Affected (0.00 sec)

Mysql> SELECT User,host,password from User;

+------+-----------+-------------------------------------------+

| User | Host | Password |

+------+-----------+-------------------------------------------+

| Root | localhost | *9F69E47E519D9CA02116BF5796684F7D0D45F8FA |

| Test |                                           %         | |

+------+-----------+-------------------------------------------+

Delete users: Drop user ' username ' @ ' host ';

mysql> DROP USER ' Test ' @ '% ';

Query OK, 0 rows Affected (0.00 sec)

Authorization permission: Grant Priv_type,... On [object_type] db_name.tb_name to ' user ' @ ' host ' [identified by ' Password '] [with GRANT OPTION];

If the user does not exist, grant directly creates

mysql> help GRANT;

Name: ' GRANT '

Description:

Syntax:

GRANT

Priv_type [(column_list)]

[, Priv_type [(column_list)] ...

On [object_type] Priv_level

To User_specification [, user_specification] ...

[REQUIRE {NONE | ssl_option [[and] ssl_option] ...}]

[With With_option ...]

Object_type:

TABLE

| FUNCTION

| PROCEDURE

Priv_level:

*

| * * All tables for all libraries

| db_name.* Specify all tables for the library

| Db_name.tbl_name Specify A table for the specified library

| Tbl_name

| Db_name.routine_name storage routines for the specified library

User_specification:

user [identified by [PASSWORD] ' PASSWORD ']

Ssl_option:

Ssl

| X509

| CIPHER ' CIPHER '

| ISSUER ' ISSUER '

| SUBJECT ' SUBJECT '

With_option:

GRANT OPTION

| Max_queries_per_hour Count

| Max_updates_per_hour Count

| Max_connections_per_hour Count

| Max_user_connections Count

View specified user authorization: Show GRANTS for ' user ' @ ' host ';

mysql> SHOW GRANTS for ' root ' @ ' localhost ';

+-------------------------------------------------------------------------------------------------------------- --------------------------+

| Grants for [email protected]

+-------------------------------------------------------------------------------------------------------------- --------------------------+

| GRANT all privileges on * * to ' root ' @ ' localhost ' identified by PASSWORD ' *9F69E47E519D9CA02116BF5796684F7D0D45F8FA ' with GRANT OPTION |

+-------------------------------------------------------------------------------------------------------------- --------------------------+

View Current user authorizations: show GRANTS for Current_User;

Recycling Authorization: REVOKE priv_type, ... On db_name.tb_name from ' user ' @ ' host ';

mysql> help REVOKE;

Name: ' REVOKE '

Description:

Syntax:

REVOKE

Priv_type [(column_list)]

[, Priv_type [(column_list)] ...

On [object_type] Priv_level

From user [, user] ...

REVOKE all privileges, GRANT OPTION

From user [, user] ...











MySQL Account management and authorization

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.