centos mysql忘记密码
时间: 2023-11-23 16:08:25 浏览: 52
以下是在CentOS系统中重置MySQL密码的步骤:
1. 停止MySQL服务:
```shell
sudo systemctl stop mysqld
```
2. 使用以下命令以跳过权限验证方式启动MySQL服务:
```shell
sudo mysqld_safe --skip-grant-tables &
```
3. 连接到MySQL服务器:
```shell
mysql -u root
```
4. 在MySQL命令行中执行以下命令来修改密码:
```shell
UPDATE mysql.user SET authentication_string=PASSWORD('新密码') WHERE User='root';
```
请将`新密码`替换为您想要设置的新密码。
5. 刷新权限:
```shell
FLUSH PRIVILEGES;
```
6. 退出MySQL命令行:
```shell
exit;
```
7. 停止MySQL服务:
```shell
sudo systemctl stop mysqld
```
8. 启动MySQL服务:
```shell
sudo systemctl start mysqld
```
现在您应该可以使用新密码登录MySQL了。
相关问题
centos7 mysql忘记密码
当您忘记CentOS 7上MySQL的密码时,可以按照以下步骤进行重置密码:
1. 首先,停止MySQL服务:
```
sudo systemctl stop mysqld
```
2. 使用以下命令以跳过身份验证方式启动MySQL服务:
```
sudo mysqld_safe --skip-grant-tables &
```
3. 连接到MySQL服务器:
```
mysql -u root
```
4. 在MySQL命令行中,使用以下命令更新root用户的密码(将YOUR_NEW_PASSWORD替换为您想要设置的新密码):
```
UPDATE mysql.user SET authentication_string=PASSWORD('YOUR_NEW_PASSWORD') WHERE User='root';
```
5. 刷新权限:
```
FLUSH PRIVILEGES;
```
6. 退出MySQL命令行:
```
exit;
```
7. 停止MySQL服务:
```
sudo systemctl stop mysqld
```
8. 启动MySQL服务:
```
sudo systemctl start mysqld
```
现在,您应该可以使用新密码登录MySQL了。
linux centos7 mysql忘记密码
对于忘记 MySQL 密码的情况,可以按照以下步骤进行重置密码:
1. 首先,停止 MySQL 服务:
```
sudo systemctl stop mysqld
```
2. 使用以下命令启动 MySQL 服务并跳过授权表验证:
```
sudo mysqld_safe --skip-grant-tables &
```
3. 进入 MySQL 命令行界面:
```
mysql -u root
```
4. 在 MySQL 命令行下,使用以下命令修改 root 用户密码:
```
FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';
```
将 `新密码` 替换为你想要设置的新密码。
5. 退出 MySQL 命令行界面:
```
exit
```
6. 停止 MySQL 服务:
```
sudo systemctl stop mysqld
```
7. 使用以下命令重新启动 MySQL 服务:
```
sudo systemctl start mysqld
```
现在你应该可以使用新密码登录到 MySQL 数据库了。请确保将 `新密码` 替换为你自己设置的密码。
相关推荐
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)