网络编程
位置:首页>> 网络编程>> 数据库>> MySql添加新用户及为用户创建数据库和给用户分配权限方法介绍

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

作者:星之刃火  发布时间:2024-01-29 01:03:10 

标签: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;

来源:https://blog.csdn.net/weixin_38981118/article/details/80467970

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com