Home >Database >Mysql Tutorial >What should I do if the error ERROR 1045 is reported after mysql is installed?
Solution: 1. Turn off the mysql service; 2. Open a terminal and enter the database in safe mode; 3. Open a new terminal and execute the "mysql -u root" command to log in to the database without a password; 4. Use the "alter user..." command to change the password; 5. Restart mysql.
(Recommended tutorial: mysql video tutorial)
1. Yesterday, I installed Mysql8.0.18 and then used navicat to connect. The result appeared:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
2. Next, I logged in to mysql from the command line and found that an error was also reported
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
1. First turn off the mysql service
$ sudo service mysql stop
2. Open the terminal
$ cd /usr/local/mysql/bin $ sudo su
3. Then execute the following command to enter safe mode Database
sh-3.2# ./mysqld_safe --skip-grant-tables &
4. Open a new terminal
$ mysql -u root
Note: At this time you will find that you can enter the database without a password
1. After entering the database safely through the above operations, perform the following operations
mysql> use mysql mysql> alter user 'root'@'localhost'IDENTIFIED BY 'MyNewPass';
Note: Mysql8.0 and above password policy restrictions must require uppercase and lowercase letters plus numbers and special symbols
Restart mysql and it will be OK
For more programming-related knowledge, please visit: Introduction to Programming! !
The above is the detailed content of What should I do if the error ERROR 1045 is reported after mysql is installed?. For more information, please follow other related articles on the PHP Chinese website!