mysql修改权限允许远程登录

mysql> use mysql;
Database changed
mysql> grant all privileges  on *.* to root@'%' identified by "password";
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

查看是否绑定了域名

#c查看my.cnf或者my.ini配置文件,检查是否绑定了域名,并将其注释掉
bind-address  =127.0.0.1 

授权

任意主机以用户root和密码mypwd连接到mysql服务器
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypwd' WITH GRANT OPTION;
mysql> flush privileges;

IP为192.168.1.102的主机以用户myuser和密码mypwd连接到mysql服务器
mysql> GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.102' IDENTIFIED BY 'mypwd' WITH GRANT OPTION;
mysql> flush privileges;

补充

with grant option的作用

表示是否具有授权的能力
举例:
grant select ,update on bd_corp to testuser1 [with grant option ]
1.如果带了 with grant option 
那么用户testuser1可以将select ,update权限传递给其他用户( 如testuser2)
grant select,update on bd_corp to testuser2
2.如果没带with grant option
  那么用户testuser1不能给testuser2授权

报错

The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

mysql> grant all on cactidb.* to dbuser@'localhost' identified by '123';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
解决方法:
先刷新一下权限表。
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> grant all on cactidb.* to dbuser@'localhost' identified by '123';
Query OK, 0 rows affected (0.00 sec)
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值