给用户设置访问数据库的权限

转载自:http://blog.csdn.net/czhphp/article/details/9664925


数据库名:test_db

用户名:test

密码  :123456

授予的权限 增,删,改,查

主机地址 172.1.1.1

 

//授权的sql语句

  grant ALL on test_db.* to 'test'@'172.1.1.1'  identified by '123456';    

//可以只授权查看

 grant select on test_db.* to'test'@'172.1.1.1'  identified by '123456';   

// 可以授权查看和更新

 grant select,update on test_db.* to'test'@'172.1.1.1'  identified by '123456'; 

 

解释:

grant ALL on *.* to 'test'@'172.1.1.1'  identified by '123456';    

第一个  *  表示数据库

第二个  *  表示表名

172.1.1.1 表示只允许ip地址为172.1.1.1的访问,可以改成 %  允许所有所有ip访问


猜你喜欢

转载自blog.csdn.net/u012377333/article/details/42003213
今日推荐