macOS Version: 13.4.1 (c) (22F770820d)
MySQL Version: 8.0.33
安装MySQL
brew install mysql
编辑mysql配置文件
vim /usr/local/etc/my.cnf
将127.0.0.1的两行注释掉
1 # Default Homebrew MySQL server config
2 [mysqld]
3 # Only allow connections from localhost
4 #bind-address = 127.0.0.1
5 #mysqlx-bind-address = 127.0.0.1
给用户及IP授权:
// 进入mysql
mysql -u root -pSunzi,.741
// 创建访问用户及IP
create user '用户X'@'10.116.23.11' identified by '用户X的密码';
// 授权
grant all privileges on *.* to '用户X'@'本机的IP' with grant option;
// 刷新授权
flush privileges;
// 退出mysql
exit
// 重启mysql
brew services restart mysql
现在就可以通过IP访问mysql了