新建用户:
mysql -u root -p
CREATE USER “test”@”localhost” IDENTIFIED BY “1234”; #本地登录
CREATE USER “test”@”%” IDENTIFIED BY “1234”; #远程登录quit
mysql -utest -p #测试是否创建成功
给用户授权:
grant 权限 on 数据库.* to 用户名@登录主机 identified by “密码”;
授权test用户拥有testDB数据库的所有权限:
grant all privileges on testDB.* to “test”@”%” identified by “1234”;
flush privileges; #刷新系统权限表
指定部分权限给用户:
grant select,update on testDB.* to “test”@”localhost” identified by “1234”;
flush privileges; #刷新系统权限表
删除用户:
mysql -u root -p
Delete FROM mysql.user Where User=”test” and Host=”%”;
flush privileges;
修改指定用户密码:
mysql -u root -p
update mysql.user set authentication_string=password(“新密码”) where User=”test” and Host=”%”;
flush privileges;