echo time login in mysql shell 它显示:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
Run Code Online (Sandbox Code Playgroud)
和错误日志显示:
Your password has expired. To log in you must change it using a client that supports expired passwords.
小智 5
通常,在脚本 shell 中,您会收到消息:“您的密码已过期。要登录,您必须使用支持过期密码的客户端更改它。”
从 MySQL 5.7.4 到 5.7.10,default_password_lifetime变量的默认值是 360(一年)。对于这些版本,如果您不更改此变量或个人用户帐户,则所有用户密码将在 360 天后过期。
要防止密码自动过期,请以 root 身份登录:
mysql -u root -p
然后,对于自动连接到服务器(例如从脚本)的客户端,更改这些客户端的密码过期设置:
ALTER USER 'script'@'localhost' PASSWORD EXPIRE NEVER;
或者只是为所有用户禁用自动密码过期:
SET GLOBAL default_password_lifetime = 0;
MySQL:密码过期和沙盒模式
MySQL:密码过期策略
MySQL Server 5.7 中的密码过期策略
您需要为您的连接启用沙盒模式。对于 mysql CLI,有一个参数来指定它:
mysql -u <user> [other params] --connect-expired-password
Run Code Online (Sandbox Code Playgroud)
然后,您必须使用SET PASSWORD语句来重置您的密码(允许将其重置为当前值)。