Home > Database > Mysql Tutorial > body text

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

青灯夜游
Release: 2020-10-29 09:08:51
Original
4597 people have browsed it

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)
Copy after login
Copy after login

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)
Copy after login
Copy after login

Solution

1. First turn off the mysql service

$ sudo service mysql stop
Copy after login

2. Open the terminal

$ cd /usr/local/mysql/bin
$ sudo su
Copy after login

3. Then execute the following command to enter safe mode Database

sh-3.2# ./mysqld_safe --skip-grant-tables &
Copy after login

4. Open a new terminal

$ mysql -u root
Copy after login

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';
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template