mac下mysql忘记密码
时间: 2023-10-22 10:29:26 浏览: 106
linux--mysql忘记密码,修改密码
5星 · 资源好评率100%
如果在Mac下忘记了MySQL的初始密码,可以按照以下步骤进行解决:
1. 打开终端。
2. 停止MySQL服务。在终端中输入以下命令并按回车键:
sudo /usr/local/mysql/support-files/mysql.server stop
3. 进入MySQL的bin目录。在终端中输入以下命令并按回车键:
cd /usr/local/mysql/bin/
4. 使用root账户。在终端中输入以下命令并按回车键,然后输入Mac密码:
sudo su
5. 运行MySQL并跳过权限验证。在终端中输入以下命令并按回车键:
./mysqld_safe --skip-grant-tables &
6. 进入MySQL命令行。在终端中输入以下命令并按回车键:
./mysql
7. 刷新权限。在MySQL命令行中输入以下命令并按回车键:
FLUSH PRIVILEGES;
8. 修改root账户的密码。在MySQL命令行中输入以下命令并按回车键,将“your_new_password”替换为你想设置的新密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'your_new_password';
9. 重启MySQL服务。在终端中输入以下命令并按回车键:
cd /usr/local/mysql
sudo ./support-files/mysql.server start
10. 使用新密码登录MySQL。在终端中输入以下命令并按回车键,将“your_new_password”替换为你设置的新密码:
/usr/local/mysql/bin/mysql -u root -p
请确保按照上述步骤操作,以解决在Mac下忘记MySQL密码的问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [MAC下MySQL忘记初始密码怎么办](https://download.csdn.net/download/weixin_38655309/12828097)[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* [MAC下MySQL初始密码忘记怎么办](https://download.csdn.net/download/weixin_38674124/12828103)[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* [mac解决mysql忘记密码的问题(亲测有效)](https://blog.csdn.net/W_317/article/details/126890954)[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 ]
阅读全文