Get the App
SLTechnology News&Howtos  ›  Servers  › 

Mysql grant configuration authorization

Shulou Source: shulou.com Published: 2022-06-03 09:00:40 10月01日 Update

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)

Tags: User password permission address user name query host place customer client network segment syntax link new secret native login configuration Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Apple Docker MariaDB NVidia