Home >Database >Mysql Tutorial >Why Am I Getting 'Access Denied for user 'root'@'localhost'' When Importing an SQL File in Ubuntu?

Why Am I Getting 'Access Denied for user 'root'@'localhost'' When Importing an SQL File in Ubuntu?

Linda Hamilton
Linda HamiltonOriginal
2024-12-10 06:16:17942browse

Why Am I Getting

Access Denied for 'root'@'localhost' Using Password: YES

When attempting to install a software suite on Ubuntu without MySQL knowledge, users may encounter the following error:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

This error arises when trying to import an SQL file using the command:

mysql -uroot -proot <"Db.sql"

To rectify this situation, understand that:

  • For MySQL versions prior to 5.7, the default root password is empty. Hence, logging in as follows should resolve the issue:
mysql -u root
  • Post-installation, immediately change the root password:
mysqladmin -u root password [newpassword]
  • For enhanced security, consider creating individual user accounts and restricting privileges.

The above is the detailed content of Why Am I Getting 'Access Denied for user 'root'@'localhost'' When Importing an SQL File in Ubuntu?. 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