Welcome 微信登录

首页 / 数据库 / MySQL / MySQL 5.6锁定用户

MySQL 5.7加入了LOCK ACCOUNT功能和Oracle一样了,但是MySQL 5.6貌似没有,但是可以代替用如下方法设置密码过期。The mysql.usertable now has a password_expiredcolumn. Its default value is "N", butcan be set to "Y"with the new ALTER USER statement. After an account"s password has beenexpired, all operations performed in subsequent connections to the server using the account resultin an error until the user issues a SET PASSWORDstatement to establish a new account password.For more information, see Section 13.7.1.1, “ALTER USERSyntax”, and Section 6.3.6, “PasswordExpiration and Sandbox Mode”.就是下面这个语法mysql> alter user mytest1@"%" password expire;如果要恢复set password for mytest1@"%" = "*******";其实就是MYSQL.USER下面的字段 password_expired 标示了是否过期。本文永久更新链接地址