https://www.cnblogs.com/pejsidney/p/9099733.html
1.登录Mysql
若环境变量配置了mysql,则直接通过命令窗口执行即可;若没有配置环境变量,则需要进入到指定的mysql路径下(/mysql/bin/)
例:mysql -uroot -padmin
说明 -u 代表是用户(user) root 为登陆用户 -p代表密码(password) admin代表为登陆密码
2.创建用户
创建用户名为 user_test1 的用户,设置密码为 user_test1&psw
例:CREATE USER ‘user_test1’ IDENTIFIED BY ‘user_test1&psw’;
ant all privileges on student.* to test3@localhost identified by ’123456′;
3.创建数据库
在 root 用户下创建数据库 test_data1 设置编码格式 (注:Mysql的版本不同编码格式会有所不同)
例:CREATE DATABASE test_data1 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
4.为创建用户授权
为新增用户授予增删改查等权限,具体看需要授权哪些就授权哪些即可,如下:
grant create,select,insert,update,delete,drop,alter on test_data1.* to user_test1@”%” identified by “user_test1&psw”;
删除fypay用户*
例1:delete from user where user=”user_test1”
例2:drop user user_test1@localhost
刷新数据库*
例:flush privileges;
5.创建用户并授权
grant 权限 on 数据库.* to 用户名@登录主机 identified by “密码”;
增加一个test1用户,密码为123456,可以在任何主机上登录,并对所有数据库有查询,增加,修改和删除的功能。需要在mysql的root用户下进行
mysql>grant select,insert,update,delete on . to test1@”%” identified by “123456″;
mysql>flush privileges;
例2:增加一个test2用户,密码为123456,只能在192.168.2.12上登录,并对数据库student有查询,增加,修改和删除的功能。需要在mysql的root用户下进行
mysql>grant select,insert,update,delete on student.* to test2@192.168.2.12 identified by “123456″;
mysql>flush privileges;
例3:授权用户test3拥有数据库student的所有权限
mysql>grant all privileges on student.* to test3@localhost identified by ’123456′;
mysql>flush privileges;
标签:test1,数据库,Mysql,用户,identified,user,mysql,权限
来源: https://blog.csdn.net/weixin_39171191/article/details/101108145