Home >Database >Mysql Tutorial >How to Reset Your MySQL Root Password After Facing Error #1045 in PHPMyAdmin?

How to Reset Your MySQL Root Password After Facing Error #1045 in PHPMyAdmin?

Patricia Arquette
Patricia ArquetteOriginal
2024-11-02 21:36:30628browse

How to Reset Your MySQL Root Password After Facing Error #1045 in PHPMyAdmin?

Forgotten MySQL root Password and Error #1045 in PHPMyAdmin

If you have forgotten your MySQL root password, you may encounter error #1045 when attempting to access PHPMyAdmin. Here's a solution to reset your password:

Steps:

  1. Locate the MySQL configuration file using the command:
mysql --help | grep -A 1 "Default options"
  1. Edit the configuration file using a text editor:
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
  1. Under the [mysqld] block, add the following line:
skip-grant-tables
  1. Save the changes and restart MySQL:
sudo service mysql restart
  1. Log into MySQL without a password:
mysql -u root
  1. Reset the root password:
> FLUSH PRIVILEGES;
> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'MyNewPass';
  1. Revert the configuration change by removing or commenting out the skip-grant-tables line.
  2. Restart MySQL again:
sudo service mysql restart

Your MySQL root password is now reset. You can now log into PHPMyAdmin and access your database.

The above is the detailed content of How to Reset Your MySQL Root Password After Facing Error #1045 in PHPMyAdmin?. 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