MySql 5.7 远程访问配置

原创
2016/12/08 17:54
阅读数 2K

修改 bind-address

# for ubuntu
vim /etc/mysql/my.cnf

[mysqld]
bind-address=0.0.0.0  # 或者指定的IP

更新 mysql root 权限

mysql -uroot -pPASSWD
use mysql;
update user set host = "%" where user="root" limit 1;
GRANT ALL PRIVILEGES ON *.* TO "root"@"%" WITH GRANT OPTION;
FLUSH PRIVILEGES;

此处 GRANT ALL PRIVILEGES ON . TO "root"@"%" IDENTIFIED BY "PASSWD" WITH GRANT OPTION;

在以往的版本中,往往是 GRANT ALL PRIVILEGES ON . TO "root"@"%" IDENTIFIED BY "PASSWD" WITH GRANT OPTION;

多加了 IDENTIFIED BY "PASSWD",在 5.7 以后便会报错,提示 Using GRANT statement to modify existing user properties other than privileges is deprecated and will be removed in future release. Use ALTER USER statement for this operation.

到这里,基本上就可以远程访问了

mysql -uroot -pPASSWD -h IP
展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部