一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

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

时间:2020-08-06 编辑:袖梨 来源:一聚教程网

本篇文章小编给大家分享一下MySql添加新用户及为用户创建数据库和给用户分配权限方法,文章代码介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。

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;

热门栏目