Error 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no) denied for user ' root ' @ ' localhost ' (using Password:no)
Description: Just installed MySQL, the first time landing.
[[email protected] ~]$ mysql-u root-1045 (28000for'root' @ 'localhost'for'root'@' localhost ' (using Password:no)
Then I will try to modify the root password of MySQL directly:
123456'localhost ' ' root ' @ 'localhost' (using Password:yes)'
The question is what I didn't figure out, the solution is as follows:
[Email protected] ~~]# mysqld_safe--user=mysql--skip-grant-tables--skip-networking & ~]$ MySQL-u root mysqlmysql > UPDATE user SET password=password (' NewPassword ') where user=' root '; #newpasswo Rd for root new password MySQL> FLUSH privileges;mysql>~~]$ mysql-u root-penter password : #输入新密码, OK
You must SET PASSWORD before executing this statement
Description: Use Safe mode to login successfully, then change password, equal to MySQL set password. After logging in, you want to create a database test. The result is:
1820 (HY000): Must SET PASSWORD before executing this statement
Workaround:
mysql>1820 (HY000): Must set PASSWORD before executing this statementmysql> set PASS WORD = PASSWORD ('123456'0 rows affected (0.03 sec) MySQL >1 row affected (0.00 sec)
I don't know why I set the password again.