远程账号添加数据库访问权限

ysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| apollo             |
| fp_db              |
| mrbs               |
| mysql              |
| otpdb              |
| performance_schema |
| test               |
+--------------------+
9 rows in set (0.00 sec)


mysql> select user,host from mysql.user;
+-----------+-----------------------+
| user      | host                  |
+-----------+-----------------------+
| fp_db     | %                     |
| otpserver | %                     |
| server    | %                     |
| otpserver | 10.100.%.%            |
| root      | 127.0.0.1             |
| root      | localhost             |
| root      | localhost.localdomain |
+-----------+-----------------------+
18 rows in set (0.00 sec)


mysql> select user,host,password from mysql.user;
+-----------+-----------------------+-------------------------------------------+
| user      | host                  | password                                  |
+-----------+-----------------------+-------------------------------------------+
| root      | localhost             | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root      | localhost.localdomain | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root      | 127.0.0.1             | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| otpserver | %                     |                                           |
| otpserver | 10.100.%.%            | *E2AF287CC34E0B196FCC1A1D7E9F72123F3ECB1A |

| root      | 192.168.217.%         | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| fp_db     | %                     | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+-----------+-----------------------+-------------------------------------------+
18 rows in set (0.00 sec)


mysql> select password('123456');
+-------------------------------------------+
| password('123456')                        |
+-------------------------------------------+
| *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+-------------------------------------------+
1 row in set (0.01 sec)


mysql> grant all privileges on fp_db.* to 'root'@'192.168.217.%';       让远程IP 段为 192.168.217.*  的 root  账号可以访问  fp_db 数据库里面的内容;
Query OK, 0 rows affected (0.00 sec)


mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

你可能感兴趣的:(linux)