Home  >  Article  >  Database  >  What should I do if the error ERROR 1045 is reported after mysql is installed?

What should I do if the error ERROR 1045 is reported after mysql is installed?

青灯夜游
青灯夜游Original
2020-10-28 09:32:084592browse

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.

What should I do if the error ERROR 1045 is reported after mysql is installed?

(Recommended tutorial: mysql video tutorial)

Error reporting problem:

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)

Solution

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

Change 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn