How to reset/change expired MySQL 5.6 password in Homestead

MySQL 5.6 introduced password expiration, so the password on your Homestead Virtual Machine may expire at some point.

SQLSTATE[HY000] [1862] Your password has expired. 
To log in you must change it using a client that supports 
expired passwords.

To change this you will need to log into MySQL running on Homestead in order to change your password to fix the expiry

vagrant ssh
mysql -u homestead -psecret

If you try and execute most commands you will be greeted with

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

Confusingly you can’t run the ALTER USER statement until you’ve changed your password… so you need to use SET PASSWORD

SET PASSWORD = PASSWORD('new_password');

https://dev.mysql.com/doc/refman/5.6/en/alter-user.html

2 comments

  • My root password expired and so I am having trouble actually running the SQL commands.

    I am not sure how to get past this section:

    “`
    $ mysql -u root -p
    Enter password:
    ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.
    “`