安装mysql
brew install mysql
We‘ve installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
To have launchd start mysql now and restart at login:
brew services start mysql
Or, if you don‘t want/need a background service you can just run:
mysql.server start
开启安全模式
mysqld_safe --skip-grant-tables
可以无密码登陆mysql
mysql -uroot -p
更改mysql 密码
update user set authentication_string=‘‘ where User=‘root‘;
原文:https://www.cnblogs.com/bandbandme/p/11607832.html