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
Release: 2024-11-02 21:36:30
Original
571 people have browsed it

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

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!

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