当前位置: 移动技术网 > IT编程>数据库>Mysql > MySql添加新用户及为用户创建数据库和给用户分配权限方法介绍

MySql添加新用户及为用户创建数据库和给用户分配权限方法介绍

2020年08月05日  | 移动技术网IT编程  | 我要评论

1.添加新用户

只允许本地ip访问

create user 'test'@'localhost' identified by '123456';

允许外网ip访问

create user 'test'@'%' identified by '123456';

刷新授权

flush privileges;

2.为用户创建数据库

create database test default charset utf8 collate utf8_general_ci; 

3.为用户分配权限

授予用户通过外网ip操作该数据库的所有去权限

grant all privileges on `testdb`.* to 'test'@'%' identified by '123456';

授予用户通过外网ip操作所有数据库的权限

grant all privileges on *.* to 'test'@'%' identified by '123456';

刷新授权

flush privileges;

 到此这篇关于mysql添加新用户及为用户创建数据库和给用户分配权限方法介绍的文章就介绍到这了,更多相关mysql添加新用户为用户创建数据库和给用户分配权限内容请搜索移动技术网以前的文章或继续浏览下面的相关文章希望大家以后多多支持移动技术网!

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网