MySQL password expire setting for users and global

At script level you will get this message. Your PhpMyAdmin will also give you error message.
Error: Unable to connect to MySQL.

Debugging errno: 1862
Debugging error: Your password has expired. To log in you must change it using a client that supports expired passwords.
Open your MySQL Command Line Control
Enter your password ( it will accept ) and then enter this
SET GLOBAL default_password_lifetime = 0;
changing default password life time
The password will never expire now.

To update password
ALTER USER 'usrname'@'localhost' IDENTIFIED BY 'new-password';
To expire any user account
ALTER USER 'user_id'@'localhost' PASSWORD EXPIRE;
Not to expire any user password
ALTER USER 'my_userid'@'localhost' PASSWORD EXPIRE NEVER
To set the password duration for all the users ( global ) , 60 days
SET GLOBAL default_password_lifetime = 60;
For a user to set a different days than the global set value
ALTER USER 'userid'@'localhost' PASSWORD EXPIRE INTERVAL 30 DAY;
In all these cases MySQL keeps the user in Sandbox Mode , that is the user is allowed for changing the password only.
PHP MYSQLI connection string
PHP MySQL functions Connecting to MySQL database

Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com




SQL Video Tutorials










We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer