macOS系统 mysql报错 1045 - [10000, 2023120215555019216824106803453438219] Access denied for 'Dale'@'xxx.xxx.xxx.xxx' (using password: YES)
时间: 2023-12-02 16:43:18 浏览: 74
在macOS系统中,当使用mysql时,可能会出现“1045 - Access denied for user 'root'@'localhost' (using password: YES)”这个错误。这个错误通常是由于密码错误或者权限问题导致的。以下是解决这个问题的步骤:
1. 确认密码是否正确。在终端中输入以下命令,使用正确的密码登录mysql:
```shell
mysql -u root -p
```
如果密码正确,你将会成功登录mysql。
2. 如果密码不正确,你可以尝试重置密码。在终端中输入以下命令:
```shell
sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
```
这个命令将会启动mysql服务,并跳过权限验证。接下来,在终端中输入以下命令:
```shell
mysql -u root
```
这个命令将会以root用户登录mysql。接下来,输入以下命令来重置密码:
```mysql
use mysql;
update user set authentication_string=password('new_password') where user='root';
flush privileges;
quit;
```
这个命令将会将root用户的密码重置为“new_password”。请确保将“new_password”替换为你想要设置的新密码。
3. 如果你仍然无法登录mysql,你可以尝试检查mysql的配置文件。在终端中输入以下命令:
```shell
sudo vi /etc/my.cnf
```
这个命令将会打开mysql的配置文件。检查文件中的用户名和密码是否正确。如果不正确,请将其更正为正确的用户名和密码。
如果你不知道正确的用户名和密码,你可以尝试使用以下命令来重置密码:
```shell
sudo mysqld_safe --skip-grant-tables &
mysql -u root
use mysql;
update user set password=PASSWORD("new_password") where User='root';
flush privileges;
quit;
```
这个命令将会将root用户的密码重置为“new_password”。请确保将“new_password”替换为你想要设置的新密码。
阅读全文
相关推荐













