搭建测试环境需要新建数据库进行权限分配
客户端工具可直接执行以下语句
create user 'testy'@'localhost' identified by '123qwe';
create user 'testy'@'%' identified by '123qwe';
flush privileges;
create database zzz_yun DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
grant all privileges on `zzz_yun`.* to 'testy'@'localhost' identified by '123qwe' with grant option;
grant all privileges on `zzz_yun`.* to 'testy'@'%' identified by '123qwe' with grant option;
flush privileges;
•all privileges:表示将所有权限授予给用户。也可指定具体的权限,如:SELECT、CREATE、DROP等。
•on:表示这些权限对哪些数据库和表生效,格式:数据库名.表名,这里写“*”表示所有数据库,所有表。如果我要指定将权限应用到test库的user表中,可以这么写:test.user
•to:将权限授予哪个用户。格式:”用户名”@”登录IP或域名”。%表示没有限制,在任何主机都可以登录。比如:”yangxin”@”192.168.0.%”,表示yangxin这个用户只能在192.168.0IP段登录
•identifie