Skip to content

Commit

Permalink
add file.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Aug 5, 2016
1 parent 0268d01 commit 3ca1982
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions Mac下重置Mysql的root密码.md
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`

0 comments on commit 3ca1982

Please sign in to comment.