Software & AppsOperating SystemLinux

How To Reset Forgotten phpMyAdmin Password on LAMP?

Ubuntu 1

If you’ve forgotten your phpMyAdmin password on a Linux, Apache, MySQL, and PHP (LAMP) stack, don’t worry. This guide will take you through the steps to reset it.

Introduction

phpMyAdmin is a popular tool for managing MySQL databases. However, if you forget your password, you won’t be able to access your databases. Fortunately, there’s a way to reset the password using command-line interface on your LAMP server.

Prerequisites

Before we start, ensure you have:

  • Root or sudo access to your LAMP server
  • Basic understanding of Linux terminal commands

Step 1: Stop the MySQL Server

First, we need to stop the MySQL server. This can be done using the following command:

sudo service mysql stop

The sudo command is used to run the following command as a superuser, or root user. The service command is used to run system services, and mysql stop tells it to stop the MySQL service.

Step 2: Start MySQL Server in Safe Mode

Next, we need to start the MySQL server in safe mode. This allows us to bypass the standard authentication process. Use the following command:

sudo mysqld_safe --skip-grant-tables &

The --skip-grant-tables option tells MySQL to start in safe mode, and the & at the end runs the command in the background.

Step 3: Log in to MySQL as Root User

Now, open a new terminal window and log in to MySQL as the root user:

mysql -u root

The -u option specifies the username to use when logging in.

Step 4: Switch to the MySQL Database

Once logged in, switch to the MySQL database using the use command:

use mysql;

Step 5: Reset the phpMyAdmin Password

Now, we can reset the password for the phpMyAdmin user. Replace new_password with your desired password:

UPDATE user SET password=PASSWORD('new_password') WHERE user='phpmyadmin';

This command updates the user table, setting the password field to the result of the PASSWORD() function, which is your new password, for the row where the user field is ‘phpmyadmin’.

Step 6: Flush Privileges

To ensure the changes take effect, flush the privileges:

FLUSH PRIVILEGES;

This command tells the server to reload the grant tables.

Step 7: Exit MySQL and Restart the Server

Finally, exit the MySQL prompt and restart the MySQL server:

exit;
sudo service mysql stop
sudo service mysql start

You should now be able to log in to phpMyAdmin using the new password you set for the phpmyadmin user.

Conclusion

Forgetting your phpMyAdmin password can be a stressful experience, but as we’ve seen, it’s relatively straightforward to reset it. Remember to choose a secure password and keep it safe. For more information on MySQL and phpMyAdmin, you can refer to the MySQL Official Documentation and the phpMyAdmin Documentation.

Can I reset my phpMyAdmin password without root or sudo access to my LAMP server?

No, you need root or sudo access to stop and start the MySQL server, which is necessary for resetting the password.

Can I reset the phpMyAdmin password if I don’t have a basic understanding of Linux terminal commands?

It is recommended to have a basic understanding of Linux terminal commands to follow the steps in this guide. However, if you are not familiar with Linux terminal commands, you can seek assistance from someone who is or consider hiring a professional to help you with the password reset process.

Leave a Comment

Your email address will not be published. Required fields are marked *