MySQL – How to Check if User’s Password Has Expired
authenticationMySQLmysql-8.0users
How can I find out if a user's password has expired in MySQL?
The MySQL version I'm using is 8.0.16.
Best Answer
This information, along with other user properties, is found in the user table in the mysql schema (database). The value 'Y' would indicate an expired password
select password_expired from mysql.user where user = 'whatever'
Any way you do this, you're probably going to have a password saved somewhere. Even MySQL 5.6 login-path is easily decryptable by anyone with the motivation. That warning said, this would be an easy solution.
In your environment script (eg ~/.profile or ~/.bashrc), set
alias mysql='mysql -uUser -pPasswd -hHostname'
(putting in your desired User, Passwd, and Hostname, of course.)
After shell relogin, you should be able to simply do
mysql
... which will use your alias and connect to the DB and ignore any passwords in .my.cnf files.
Security note: If there are other users on your server, you might want to chmod 700 your profile script so the password is not as easily accessed by others. Any admin with root or sudo will be able to see it still; no way around that.
Best Answer
This information, along with other user properties, is found in the
user
table in themysql
schema (database). The value'Y'
would indicate an expired password