MySQL添加新用户、为用户创建数据库、为新用户分配权限
登录MySQL
mysql -u root -p
添加新用户
允许本地 IP 访问 localhost, 127.0.0.1
create user 'test'@'localhost' identified by '123456';
允许外网 IP 访问
create user 'test'@'%' identified by '123456';
刷新授权
flush privileges;
为用户创建数据库
create database test DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
为新用户分配权限
授予用户通过外网IP对于该数据库的全部权限
grant all privileges on `testdb`.* to 'test'@'%' identified by '123456';
授予用户在本地服务器对该数据库的全部权限
grant all privileges on `testdb`.* to 'test'@'localhost' identified by '123456';
刷新权限
flush privileges;
原文地址:https://segmentfault.com/a/1190000014909256
相关推荐
-
Mac下nginx配置http2 服务器
2020-6-9
-
MySQL数据库之视图 服务器
2019-8-18
-
开源堡垒机jumpserver搭建 服务器
2019-8-29
-
深入浅出 Viewport 设计原理 服务器
2020-7-1
-
yum安装CDH5.5 hive、impala 服务器
2020-6-22
-
MySQL语句和命令大全 服务器
2019-7-20
-
8 个安全性最高的 Linux 发行版推 服务器
2020-6-8
-
关于服务器性能排查的思考 服务器
2019-4-4
-
Field redisTemplate in xxxxxx required a bean of type ‘org.springframework.data.redis.core.RedisTemplate’ that could not be found. 服务器
2019-10-7
-
如何快速清理 docker 资源 服务器
2019-3-25