欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-07-10 12:55:33
1.添加新用户只允许本地ip访问create user 'test'@'localhost' identified by '123456';允许外网ip访问create user 'test'@'%'...

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