Mac下mysql不能远程访问问题
1、进MySQL之后
2、输入以下语句,进入mysql库:
use mysql;
3、更新域属性,’%'表示允许外部访问:
update user set host='%' where user ='root';
4、执行以上语句之后再执行(刷新配置):
FLUSH PRIVILEGES;
5、再执行授权语句:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION;
本文测试环境: MacOS 10.13 MySQL8.0.15
macOS上mysql使用的配置文件地址,通过下面命令查看
mysql --verbose --help | grep my.cnf
输出:
编辑cnf文件
cat /usr/local/etc/my.cnf
Default Homebrew MySQL server config [mysqld] Only allow connections from localhost bind-address = 127.0.0.1 mysqlx-bind-address = 127.0.0.1
将bind-address,mysqlx-bind-address
改为0.0.0.0
重起mysql
brew service restart mysql
参考:
https://www.cnblogs.com/tingguoguoyo/p/11005584.htm https://blog.csdn.net/kelvin_yin/article/details/81154285