天天看點

mysql 隻讀賬号_mysql建立隻讀使用者

mysql建立隻讀使用者

[[email protected] ~]# mysql -ugateway -p

Enter password:

Welcome to the MySQL monitor. Commands end

with ; or \g.

Your MySQL connection id is 49326

Server version: 5.6.39-log MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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> use mysql;

Reading table information for completion of table and column

names

You can turn off this feature to get a quicker startup with

-A

Database changed

mysql> SELECT host,user,password FROM user;

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

| host | user | password |

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

| 127.0.0.1 | root |

*9ED0711B436788AD490306F0A5DFC3B36D5EABC9 |

| % | gateway |

*F8E091073F1BFFCA333567290E5651A21447D76F |

| % | universalpay |

*2A8C0DFCBDC1A386C5A9A43B5439AD64C4B52309 |

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

3 rows in set (0.00 sec)

mysql> show databases;

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

| Database |

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

| information_schema |

| 開發庫 |

| com_db |

| gateway |

| mysql |

| performance_schema |

| universalpay |

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

7 rows in set (0.00 sec)

mysql> GRANT SELECT ON gateway.* TO 'ro_user01'@'%'

IDENTIFIED BY "ro_user0101";

Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.04 sec)

mysql> SELECT host,user,password FROM user;

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

| host | user | password |

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

| 127.0.0.1 | root |

*9ED0711B436788AD490306F0A5DFC3B36D5EABC9 |

| % | gateway |

*F8E091073F1BFFCA333567290E5651A21447D76F |

| % | universalpay |

*2A8C0DFCBDC1A386C5A9A43B5439AD64C4B52309 |

| % | ro_user01 | *F158D11AF06DCD626315B1BC55C12BCE4EAEECA8

|

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

4 rows in set (0.00 sec)

mysql> show grants for ro_user01;

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

| Grants for ro_user01@% |

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

| GRANT USAGE ON *.* TO 'ro_user01'@'%' IDENTIFIED BY PASSWORD

'*F158D11AF06DCD626315B1BC55C12BCE4EAEECA8' |

| GRANT SELECT ON `gateway`.* TO

'ro_user01'@'%' |

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

2 rows in set (0.00 sec)

!!!The end!!!