forked from jaywcjlove/handbook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0268d01
commit 3ca1982
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
# Mac下重置Mysql的root密码 | ||
|
||
|
||
```bash | ||
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) | ||
# 或者 | ||
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) | ||
``` | ||
|
||
|
||
## 停止 mysql server | ||
|
||
`系统偏好设置` > `MySQL` > `Stop MySQL Server` | ||
|
||
|
||
## 终端,输入 | ||
|
||
``` | ||
sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables | ||
``` | ||
|
||
## 新开终端,输入 | ||
|
||
|
||
```bash | ||
sudo /usr/local/mysql/bin/mysql -u root | ||
# 输入 Mac 系统用户密码后, | ||
# 直接敲回车进入 mysql 终端,输入: | ||
UPDATE mysql.user SET authentication_string=PASSWORD('新密码') WHERE User='root'; | ||
FLUSH PRIVILEGES; | ||
# 输入 \q 退出 mysql 终端 | ||
\q | ||
``` | ||
|
||
## 重启MySQL. | ||
|
||
```bash | ||
ps -ef | grep mysql | ||
``` | ||
|
||
通过上面命令查看进程编号。 | ||
|
||
通过`sudo kill 93`杀掉`mysql`进程 | ||
|
||
`系统偏好设置` > `MySQL` > `Start MySQL Server` |