小编典典

Mysql密码已过期。无法连接

mysql

我只是擦了擦Mac,然后重新安装了El Capitan。我正在努力连接到Mysql。通过Web服务器设置过程,我创建了一个简单的PHP测试文件:

<?php
  $conn = new mysqli("127.0.0.1", "root", "xxxxxxxx");
  if ($conn->connect_error) echo "Connection failed: " . $conn->connect_error; 
  else echo "Connected successfully";
  phpinfo();
?>

运行它时,出现以下错误:

Warning: mysqli::mysqli(): (HY000/1862): Your password has expired. To log in you must change it using a client that supports expired passwords. in /Users/rich/Documents/DESIGN/test/index.php on line 3
Connection failed: Your password has expired. To log in you must change it using a client that supports expired passwords.

我以前从未见过来自连接的响应。如果无法连接该如何解决?

编辑

在终端中,我输入了以下命令:

mysql -u root -p

这要求我输入我输入的密码(当前密码)。我现在可以访问mysql命令,但是我尝试执行的任何操作都会导致此错误:

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

如何使用重置密码ALTER USER


阅读 299

收藏
2020-05-17

共1个答案

小编典典

所以我终于找到了解决方案。

首先,我进入终端并输入:

mysql -u root -p

这要求输入我当前输入的密码,并允许我提供更多的mysql命令。我从这里尝试过的任何操作都会出现此错误:

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

这很令人困惑,因为我实际上看不到使用ALTER USERstatement 重置密码的方法,但是我确实找到了另一个简单的解决方案:

SET PASSWORD = PASSWORD('xxxxxxxx');

2020-05-17