Home > Database > Mysql Tutorial > How to Fix MySQL ERROR 1045 (28000): Access Denied for User 'root'@'localhost'?

How to Fix MySQL ERROR 1045 (28000): Access Denied for User 'root'@'localhost'?

Patricia Arquette
Release: 2024-12-21 08:28:10
Original
657 people have browsed it

How to Fix MySQL ERROR 1045 (28000): Access Denied for User 'root'@'localhost'?

How to Resolve "ERROR 1045 (28000)" in MySQL

During the installation of software on Ubuntu, an error message "ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)" may arise when attempting to import a database file using the following command:

mysql -uroot -proot <"Db.sql"
Copy after login

Cause of the Error:

This error occurs because the default root password for MySQL is empty (or blank), not root.

Solution:

To resolve the error and continue:

  1. Log in without a password:
mysql -u root
Copy after login
  1. Set a new root password:
mysqladmin -u root password [newpassword]
Copy after login
  1. Re-import the database file:

Navigate to the directory containing the database file and re-import it with the new password:

cd ~/Desktop/iPDC-v1.3.1/DBServer-1.1
mysql -uroot -p[newpassword] <"Db.sql"
Copy after login

Additional Tips:

  • For MySQL versions 5.7 and above, refer to the recommended solution by Lahiru in the provided link.
  • Consider setting up individual user accounts for database operations to ensure data integrity.

The above is the detailed content of How to Fix MySQL ERROR 1045 (28000): Access Denied for User 'root'@'localhost'?. For more information, please follow other related articles on the PHP Chinese website!

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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template