需求:只允许某个用户访问某个库# 建立用户user能在任何ip登录,并且密码是passwdcreate user 'user'@'%' identified by 'passwd';# 授权:授予user用户能用密码passwd从任何ip登录并且有访问ctoms_test数据库任何资源的所有权限grant all privileges on ctoms_test.* to user@'%' identified by 'passwd'; # 刷新权限flush privileges;# 查看自己刚刚建立的用户SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;