用户 创建用户 create user 'userName'@'ip' identified by 'passWord'; userName 为将要创建的用户;ip 为机器地址,表示创建的用户可以在哪个机器上登陆;‘userName’@‘ocalhost‘,该用户只能在本地登录,不能在另外一台机器上远程登录; ‘userName’@’%‘,该用户在任何一台电脑上都可以登录; 也可以指定某台机器可以远程登录;password 为用户密码; 删除用户 drop user 'userName'@'ip'; 更改用户密码 set password for 'userName'@'ip' = password('newPassword'); # 例 set password for 'csx_read'@'localhost' = password('1234'); 权限 授权用户 GRANT privileges ON databaseName.tableName TO 'userName'@'ip' privileges 将要授权的权限(insert, select, update, delete …), 所有权限可以写为 all privileges;databaseName 数据库名称;tableName 数据库中的表名称,若要授权所有表,则可写为 databaseName.* ; grant select on csx.* to 'csx_read'@'localhost'; grant insert,select,update,delete on csx.* to 'csx_write'@'localhost'; 刷新权限 flush privileges; 查看权限 show grants for 'userName'@'ip'; 例 show grants for 'csx_read'@'localhost'; 结果 取消授权 revoke privileges on databaseName.tableName FROM 'userName'@'ip'; 例 revoke select on csx.* from 'csx_read'@'localhost'; 结果