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添加新用户为用户创建数据库和给用户分配权限内容请搜索www.887551.com以前的文章或继续浏览下面的相关文章希望大家以后多多支持www.887551.com!