如下所示:
主要执行授权命令:
两种方式
1. 允许任意主机以用户bd和密码bdpw连接到local服务器
12 | mysql> grant all privileges on *.* to 'bd' @ '%' identified y 'bdpw' with grant option ; mysql> flush privileges ; |
2. 允许特定的ip地址以用户bd和密码bdpw连接到local服务器
12 | mysql> grant all privileges on *.* to 'bd' @ '172.16.4.198' dentified by 'bdpw' with grant option ; mysql> flush privileges ; |
注意:
1. 在command line client输入密码 或 进入nivacat的命令行界面,
2. 输入:use mysql;
3. 查询host输入: select user,host from user;
如果有host值为%的,则直接执行授权语句;如果没有,则执行第4步
4. 创建host
如果没有”%”这个host值,选择某个开放出去的用户(bd),执行
12 | mysql> update user set host= '%' where user = 'bd' ; mysql> flush privileges ; |
5. 授权用户*.* 表明授权所有权限
12 | mysql> grant all privileges on *.* to 'bd' @ '%' identified by 'bdpw' with grant option ; mysql> flush privileges ; |