Chinaunix首页 | 论坛 | 博客
  • 博客访问: 63108
  • 博文数量: 16
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 125
  • 用 户 组: 普通用户
  • 注册时间: 2015-04-23 09:29
文章分类

全部博文(16)

文章存档

2016年(10)

2015年(6)

我的朋友

分类: Mysql/postgreSQL

2015-12-24 16:12:49

通过修改数据表为mysql添加远程访问权限,首先要进入到mysql终端,然后
>use mysql
>grant all privileges on *.* to 'username'@'host' identified by 'password' with grant option;
注释:
all privileges: 代表所有的操作权限,如增删改查,也可单独指定操作,多个操作用逗号隔开,如select,update
*.*:代表数据库和表,星号为通配符,代表所有的数据库下的所有表
usernamepassword分别为用户名和密码
host为mysql客户端地址,host为“%”时,表示任何客户端地址都可以连接到mysql服务器
with grant option 的作用是允许当前被授权的用户将这些权限授予其他用户

示例:
1、用户username使用密码password从任何地址连接mysql数据库,并且可以访问任何数据
grant all privileges on *.* to 'username'@'%' identified by 'password' with grant option;

2、用户username使用密码password从121.99.40.45地址连接mysql数据库,并且可以访问任何数据
grant all privileges on *.* to 'username'@'121.99.40.45' identified by 'password' with grant option;

3、用户username使用密码password从121.99.40.45地址连接mysql数据库,可以访问test_db数据库
grant all privileges on test_db.* to 'username'@'121.99.40.45' identified by 'password' with grant option;


修改连接mysql服务器的密码
>alter user 'username'@'host' identified by 'new password';

阅读(1261) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~