ERROR 1820 (HY000): You must SET PASSWORD before executing this statement


I was trying to install the MYSQL Ver 14.14 Distrib 5.6.21, from mysql.com instead of using the default shipped MySQL with RHEL6.

Post-installation, the temporary password gets stored in /root/.mysql_secret. You login to MySQL Database using:

mysql -u root -pXXXXX
Then connect to database:

If you try any further operation, you'll see an mysql ERROR:

PROBLEM 
mysql> select * from user;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
To get past this, set the password for root like this:

SOLUTION 

mysql>  SET PASSWORD for root@'localhost' = PASSWORD('secret');
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

Note : Replace word "secret" with desired password 
Now try logging in using the newly set password and you're good to go.
 
Top
Maintained By Amit Maheshwari