Skip to content

Commit

Permalink
update .
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Aug 12, 2016
1 parent ad351fb commit ee7fabd
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions MySQL/Mac下重置MySQL的root密码.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

# 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 -uroot -p` 登录进去。

## 停止 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 终端,输入:
mysql> FLUSH PRIVILEGES;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
# 输入 \q 退出 mysql 终端
\q
```

## 重启MySQL.

```bash
ps -ef | grep mysql
```

通过上面命令查看进程编号。

通过`sudo kill 93`杀掉`mysql`进程

`系统偏好设置` > `MySQL` > `Start MySQL Server`


更快捷的重启

```bash
sudo /usr/local/mysql/support-files/mysql.server start

```


# 官网参考


- [ How to Reset the Root Password](http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html)

0 comments on commit ee7fabd

Please sign in to comment.