Mac安装mysql
Mac安装homebrew
安装mysql通过homebrew
注意,如果之前已经安装过的话,需要先删除如下的文件或者目录;如果是全新安装,这一步可以忽略
rm -rf /usr/local/etc/my.cnf*
rm -rf /usr/local/Cellar/mysql@5.7/
rm -rf /System/Volumes/Data/usr/local/Cellar/mysql@5.7
rm -rf /System/Volumes/Data/usr/local/etc/my.cnf
rm -rf /System/Volumes/Data/usr/local/Cellar/mysql@5.7
1、执行安装命令
rew install mysql@5.7 # 这里一定要加上版本号,否则是安装最新的,比如最新的是8.0.19,则可能有些早期的mysql客户端无法链接
安装完后默认是没有密码的,
启动mysql
/opt/homebrew/opt/mysql@5.7/bin/mysql.server start
停止mysql
/opt/homebrew/opt/mysql@5.7/bin/mysql.server start
修改密码
/opt/homebrew/opt/mysql@5.7/bin/mysqladmin -u root password 123456
/opt/homebrew/opt/mysql@5.7/bin/mysql_secure_installation