mysql uroot proot_在本地使用mysql -h192.168.1.130 -P3306 -uroot -proot 不能登录,在远程mysql服务器中使用mysql -uroot -p...

在本地使用MySQL Server 5.7\bin>mysql -h192.168.1.130 -P3306 -uroot -proot

登录远程mysql 出现一下错误。Warning: Using a password on the command line interface can be insecure.

ERROR 2003 (HY000): Can't connect to MySQL server on '10.34.16.100' (10061)

原因是ip地址为mysql不能监听到私有ip。在远程mysql中找到mysql.cnf 文件将bind-address = 127.0.0.1

这项配置注释或改为bind-address = 0.0.0.0    //用于监听所有ip

之后重启mysql 服务器sudo systemctl  restart mysql      // ubuntu中命令

再次在本地登录mysql -h192.168.1.130 -P3306 -uroot -proot

可能会返回Warning: Using a password on the command line interface can be insecure.

ERROR 1130 (HY000): Host '192.168.1.130' is not allowed to connect to this MySQL

是因为192.168.1.130 没有访问数据库的权限,在远程mysql 服务器中使用root权限登录create user  'your user name'@'192.168.1.130' identified by 'your password';     -- 为此连接创建一个新用户, 不需要为其分配新用户可以直接授权grant all privileges on *.* to 'your user name'@'192.168.1.130' identified by 'your password' ; -- 对新创建的用户授权,all privileges 表示授予其root, 此项可根据自己的选择只授予select update insert 或delete 权限。

flush privileges ;

在本地使用新用户登录()mysql -h192.168.1.130 -P3306 -u'your user name'  -p'your password'

应该就能登录到远程mysql

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值