centos7mysql密码重置
时间: 2023-09-19 12:10:26 浏览: 102
在CentOS 7上重置MySQL的root密码有几种方法。一种方法是通过使用mysqladmin来重置密码。首先,确保你有系统的root权限。然后,打开终端并输入以下命令来停止MySQL服务:
```
sudo systemctl stop mysqld
```
接下来,输入以下命令来以跳过权限验证的方式启动MySQL服务:
```
sudo mysqld_safe --skip-grant-tables &
```
然后,输入以下命令来连接到MySQL服务器:
```
mysql -u root
```
在MySQL提示符下,输入以下命令来更新root用户的密码:
```
UPDATE mysql.user SET authentication_string=PASSWORD('your_new_password') WHERE User='root';
```
注意将`your_new_password`替换为你想要设置的新密码。然后,输入以下命令以刷新权限表:
```
FLUSH PRIVILEGES;
```
最后,输入以下命令来退出MySQL:
```
exit;
```
现在你可以使用新密码登录MySQL了。请确保在完成密码重置后重新启动MySQL服务,使用以下命令:
```
sudo systemctl start mysqld
```
请注意,这是一种通过使用mysqladmin的方法来重置MySQL的root密码,还有其他方法可以实现相同的目标。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Linux下重置mysql密码(Centos7)](https://blog.csdn.net/u012756235/article/details/104829446)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [centos7下mysql忘记密码并修改](https://blog.csdn.net/qq_27619943/article/details/127787948)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [CentOS下重置MySQL的root密码的教程](https://download.csdn.net/download/weixin_38530995/12830134)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文