搜索版本 :
brew search mysql
安装 Mysql :
brew install mysql@5.7
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
mysql@5.7 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have mysql@5.7 first in your PATH, run:
echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
......
echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
brew services start mysql@5.7
mysql -uroot
show databases;
# 连接数据库
mysql -u root
# 选择 mysql 库
use mysql
# 修改密码
update user set authentication_string=password('新密码') where user='root';
# 刷新权限
flush privileges;