参考:mysql 官方重置密码
- 杀掉mysql进程
1 | shell> kill `cat /mysql-data-directory/host_name.pid` |
重写init.sql
1
2
3
4--MySQL 5.7.6 and later:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
--MySQL 5.7.5 and earlier:
--SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');用mysql-init启动mysql
1
2mysqld --init-file=/initFilePath &
sudo mysqld --init-file=/Users/lineworks/Documents/utilities/mysql/mysql-init &