You must SET PASSWORD before executing this statement solution

  • 2020-05-24 06:20:23
  • OfStack

If you successfully log in using secure mode and change your password, you are setting a password for MySql. After logging in, I want to create a database for testing. The results are true:

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

Very weird ah, clearly logged in with a password, how to prompt the need for a password.
1 refer to official document, see http: / / dev mysql. com/doc refman / 5.6 / en/alter - user. html. ok will be completed after the following operations:

mysql > create database yan1;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql > SET PASSWORD = PASSWORD('123456');
Query OK, 0 rows affected (0.03 sec)

mysql > create database yan1;
Query OK, 1 row affected (0.00 sec)


So mysql > SET PASSWORD = PASSWORD (' 123456 '); Reset the password once! Grandpa's. It's hard work.
This guy has the same problem.


Recently installed mysql always has an error when entering the mysql tool:

# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
or
# mysql -u root -p password 'newpassword'
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'

A solution has finally been found. I was going to reload it, but I don't need it now.
The method is simple to operate, as follows:
# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql > UPDATE user SET Password=PASSWORD('newpassword') where USER='root' and host='root' or host='localhost'; // change all empty user passwords to non-empty passwords.
mysql > FLUSH PRIVILEGES;
mysql > quit # /etc/init.d/mysqld restart
# mysql -uroot -p
Enter password: < Enter the new password newpassword >

MySql5.6 operation times error: You must SET PASSWORD before executing this statement
mysql > SET PASSWORD = PASSWORD('123456');
Query OK, 0 rows affected (0.03 sec)
mysql > create database roger;
Query OK, 1 row affected (0.00 sec)
So mysql > SET PASSWORD = PASSWORD (' 123456 '); Reset the password once!

Related articles: