前言
- mysql 5.7.31
mysql创建账号并赋予权限
为新的数据库flowdb
,创建账户flowdba
。将flow
库的所有权限赋予flowdba
账户。
操作步骤
- 创建
flowdba
账户
mysql> use mysql;
Database changed
mysql> create user 'flowdba'@'%' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> select host,user,authentication_string from user;
+-------------------------+---------+------------------------------------------- +
| host | user | authentication_string |
+-------------------------+---------+------------------------------------------- +
| localhost | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| izm5e0k0bexacam32zw837z | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| 127.0.0.1 | root | |
| ::1 | root | |
| localhost | | |
| izm5e0k0bexacam32zw837z | | |
| % | flowdba | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+-------------------------+---------+------------------------------------------- +
7 rows in set (0.00 sec)
# 将flow数据库所有权限赋给flowdba用户
mysql> grant all privileges on flow.* to 'flowdba'@'%';
Query OK, 0 rows affected (0.00 sec)
# 刷新权限
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
查看赋权结果:
mysql> use mysql;
# 表级的用户权限
mysql> select * from `db` where `user`='flowdba';
# 系统级的用户权限
mysql> select * from `user` where user='flowdba';
参考
https://www.cnblogs.com/anzerong2012/p/10738186.html