mysql授权允许远程访问

数据库 piniu 1202浏览 0评论

授权允许远程访问
一、授权命令:

授权格式:grant 权限 on 数据库.* to 用户名@登录主机 identified by “密码”; 

示例1: 授权用户拥有所有数据库的所有权限

grant all privileges on *.* to 'your_username'@'%' identified by 'your_password';

示例2:授权test用户拥有数据库(mydb)的某些权限的远程操作权限:

grant select,delete,update,create,drop on mydb.* to test@"%" identified by "12345678";

其中常用的权限有select,insert,update,delete,alter,create,drop等。

二、刷新授权:

flush privileges; 

此时,可以进行远程连接了,(注: 记得一定要把防火墙添加为允许访问 )

三、关闭授权(如果不想让该用户登录了,可以关闭授权)

revoke all on *.* from 'your_username'@'%';

发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • * 昵称:
  • * 邮箱: