1.brew install mysql
Homebrew 安装软件的位置: /usr/local/Cellar
2.bash mysql.server start
启动MySQL
3.mysql -u root -p
提示输入密码:直接enter 默认没有密码
4.修改密码
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpassword');
5.如果出现问题:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
依次执行
unset TMPDIR
bash mysql_install_db --verbose --user=root
--basedir="$(brew --prefix mysql)"--datadir=/usr/local/var/mysql --tmpdir=/tmp
#接下来启动mysql
bash mysql.server start
mysql -u root -p