数据库管理用户权限
MySQL添加新用户、为用户创建数据库、为新用户分配权限
https://blog.csdn.net/u013216667/article/details/70158452
登录MySQL
1
|
mysql -u root -p |
添加新用户
允许本地 IP 访问 localhost, 127.0.0.1
1
|
create user 'test' @ 'localhost' identified by '123456' ; |
允许外网 IP 访问
1
2
|
create user 'test' @ '%' identified by '123456' ; |
1
|
flush privileges; |
为用户创建数据库
1
|
create database test DEFAULT CHARSET utf8 COLLATE utf8_general_ci; |
为新用户分配权限
授予用户通过外网IP对于该数据库的全部权限
1
|
grant all privileges on `testdb`.* to 'test' @ '%' identified by '123456' ; |
1
|
grant all privileges on `testdb`.* to 'test' @ 'localhost' identified by '123456' ; |
刷新权限
1
|
flush privileges; |
1
|
exit |
1
|
mysql -u test -h 115.28.203.224 -p |
在Ubuntu服务器下,MySQL默认是只允许本地登录,因此需要修改配置文件将地址绑定给注释掉:
1
2
3
|
# Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. #bind-address = 127.0.0.1 #注释掉这一行就可以远程登录了 |
社会之所以进步,是因为有足够的人留下痕迹。