Question: After upgrading MySQL to version 5.7, I’m not able to create a user or set password using GRANT query. Here’s the error message: Unknown column password_last_changed in ‘mysql.user’.
For e.g.,
mysql> GRANT ALL PRIVILEGES ON db_name.* TO 'db_user'@localhost IDENTIFIED BY 'mypass'; ERROR 1054 (42S22): Unknown column 'password_last_changed' in 'mysql.user'
Solution:
The issue was due to the MySQL update. MySQL versions less than 5.7 used column ‘password_last_changed’ and it was subsequently removed in version 5.7. So after the update, you need to run mysql_upgrade command to migrate the tables from old version to newer version.
$ mysql_upgrade
The output should indicate that the tables are being upgraded to the newer version. Once done, you need to restart MySQL server.
$ /etc/init.d/mysqld restart.
That’s it!
You might be interested in solutions for common MySQL errors.