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

Mysql grant configuration authorization

2025-05-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Create a new user admin1 with full access to all database tables, allowing access from anywhere with a password of 123456

Query OK, 0 rows affected, 1 warning (0.00 sec)

The syntax is

Grant permission list on library name. Table name user name @ "user address" identified by "password" [with grant opion]

Mysql > grant all on. To admin2@ "" identified by "123456" with grant option

Query OK, 0 rows affected, 1 warning (0.00 sec)

All matches all permissions

. Match all libraries and tables

"%" matches all hosts

Authorized user admin3 allows access to the 192.168.4.0 Universe 24 network segment

Mysql > grant all on. To admin3@'192.168.4.0/24' identified by "123456" with grant option

Query OK, 0 rows affected, 1 warning (0.00 sec)

User admin4 only has query permission in daydb4.user1. Login password is 123456.

Mysql > grant select on daydb4.user1 to admin4@ "localhost" identified by "123456" with grant option

Query OK, 0 rows affected, 1 warning (0.00 sec)

Authorize admin5 to allow local access, query any daydb4 table, change insert and delete permission password 123456

Mysql > grant select,update,delete,insert on daydb4.* to admin4@ "localhost" identified by "123456" with grant option

Query OK, 0 rows affected, 1 warning (0.01 sec)

Users view their own authorization

Mysql > show grants

+-- +

| | Grants for root@localhost |

+-- +

| GRANT ALL PRIVILEGES ON. TO 'root'@'localhost' WITH GRANT OPTION |

| | GRANT PROXY ON'@''TO 'root'@'localhost' WITH GRANT OPTION |

+-- +

2 rows in set (0.00 sec)

Root view the authorization of other people's users

Show grant for user name @ "client address"

Mysql > show grants for admin4@ "localhost"\ g

+-+

| | Grants for admin4@localhost |

+-+

| GRANT USAGE ON. TO 'admin4'@'localhost' |

| | GRANT SELECT, INSERT, UPDATE, DELETE ON daydb4.* TO 'admin4'@'localhost' WITH GRANT OPTION | |

| | GRANT SELECT ON daydb4.user1 TO 'admin4'@'localhost' WITH GRANT OPTION |

+-+

3 rows in set (0.00 sec)

Change the password after the user links

Set password=password ("New password")

[root@MySQL50] # mysql-uadmin4-p654321

[root@MySQL50] # mysql-uadmin4-p654321

Mysql: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 41

Server version: 5.7.17 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

Affiliates. Other names may be trademarks of their respective

Owners.

Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.

Mysql >

Mysql > set password=password ("123456")

Query OK, 0 rows affected, 1 warning (0.00 sec)

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

Servers

Wechat

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

12
Report