场景
- Mac OS
- 通过brew安装MySQL 8
步骤
- shutdown mysql服务
brew services stop mysql
- 进入mysql安装目录
// 查看mysql安装目录:brew info mysql
cd /usr/local/Cellar/mysql/8.0.16/bin
- 启动mysql,免密登陆
./mysqld_safe --skip-grant-tables --user=root &
- 修改root密码为''
mysql -uroot
update mysql.user set authentication_string='' where user='root';
- shutdown mysql服务
ps -ef | grep mysql
kill 9 【mysql进程号】
- 通过brew启动mysql服务,修改root密码
brew services start mysql
mysql -uroot -p (提示输入密码时直接enter)
ALTER user 'root'@'localhost' IDENTIFIED BY 'Soon123@';