Mysql密码已过期.无法连接 [英] Mysql password expired. Can't connect

查看:350
本文介绍了Mysql密码已过期.无法连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚擦掉Mac并重新安装了El Capitan.我正在努力连接到Mysql.经历了Web服务器设置过程之后,我创建了一个简单的PHP测试文件:

I just wiped my Mac and did a fresh install of El Capitan. I'm struggling to connect to Mysql now. Having gone through a web server setup process, I've created a simple PHP test file:

<?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();
?>

运行它时,出现此错误:

When I run it, I get this error:

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.

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

I've never seen that response from a connection before. How do I fix it if I can't connect?

编辑

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

In terminal I entered the command:

mysql -u root -p

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

This asked me for my password (current one) which I put in. I now have access to mysql commands but anything I try results in this error:

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

如何使用ALTER USER重设密码?

推荐答案

所以我终于找到了自己的解决方案.

So I finally found the solution myself.

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

Firstly I went into terminal and typed:

mysql -u root -p

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

This asked for my current password which I typed in and it gave me access to provide more mysql commands. Anything I tried from here gave this error:

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

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

This is confusing because I couldn't actually see a way of resetting the password using ALTER USER statement, but I did find another simple solution:

SET PASSWORD = PASSWORD('xxxxxxxx');

这篇关于Mysql密码已过期.无法连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆