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 manage and authorize MYSQL account

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly introduces how to manage and authorize the MYSQL account, the content of the article is carefully selected and edited by the author, has a certain pertinence, and is of great significance to everyone's reference. Let's work with the author to understand how to manage and authorize the MYSQL account.

User account: 'user'@'host'

Create 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 user: DROP USER 'username'@'host'

Mysql > DROP USER 'test'@'%'

Query OK, 0 rows affected (0.00 sec)

Authorization: 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 creates directly.

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 of all libraries |

| | db_name.* specifies all tables of the library |

| | db_name.tbl_name specifies the specified table of the library |

| | tbl_name |

| | db_name.routine_name specifies the storage routine of the 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 the specified user authorization: SHOW GRANTS FOR 'user'@'host'

Mysql > SHOW GRANTS FOR 'root'@'localhost'

+- -+

| | Grants for root@localhost |

+- -+

| | GRANT ALL PRIVILEGES ON *. * TO 'root'@'localhost' IDENTIFIED BY PASSWORD' * 9F69E47E519D9CA02116BF5796684F7D0D45F8FA' WITH GRANT OPTION |

+- -+

View current user authorization: SHOW GRANTS FOR CURRENT_USER

Recycling license: 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]...

After reading the above about how to manage and authorize MYSQL accounts, many readers must have some understanding. If you need more industry knowledge and information, you can continue to follow our industry information section.

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

Database

Wechat

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

12
Report