1.修改mysql配置,由于是通過brew安裝的mysql,配置文件在:/usr/local/etc/my.cnf疤剑;
找到:bind-address = 127.0.0.1
修改為:bind-address = 0.0.0.0
然后mysql重啟:
mysql.server restart
題外話:怎么知道m(xù)ysql的配置文件在哪里呢?
mysql --help
2.給root用戶增加遠程登錄權(quán)限:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'passwd' WITH GRANT OPTION;
3.新建用戶敛助,增加遠程登錄權(quán)限:
CREATE USER 'www'@'%' IDENTIFIED BY 'www';
GRANT ALL PRIVILEGES ON *.* TO ‘www’@’%’ IDENTIFIED BY ‘passwd’ WITH GRANT OPTION;
FLUSH PRIVILEGES;
第一句:創(chuàng)建用戶www捻浦,密碼www晤揣,可以遠程登錄;
第二句:
給www用戶授權(quán)*.*(*.*代表所有庫表權(quán)限朱灿,前面*可以替換為database昧识,后面*可以替換為table);
‘www’@'%':www為用戶名盗扒,%為任意ip,也可以指定跪楞,比如‘www’@'192.168.1.11';
IDENTIFIED BY ‘passwd’:指遠程登錄密碼為passwd。
第三句:?刷新權(quán)限.
參考:
https://blog.csdn.net/feixiang2039/article/details/81164136
https://cloud.tencent.com/developer/article/1403533