I forgot my Phpmyadmin username and password?

46,185

Solution 1

reset mysql's root password

Stop MySQL

The first thing to do is stop MySQL. If you are using Ubuntu or Debian the command is as follows:

sudo /etc/init.d/mysql stop

For CentOS, Fedora, and RHEL the command is:

sudo /etc/init.d/mysqld stop

Safe mode

Next we need to start MySQL in safe mode - that is to say, we will start MySQL but skip the user privileges table. Again, note that you will need to have sudo access for these commands so you don't need to worry about any user being able to reset the MySQL root password:

sudo mysqld_safe --skip-grant-tables &

Note: The ampersand (&) at the end of the command is required.

Login

All we need to do now is to log into MySQL and set the password.

mysql -u root

Note: No password is required at this stage as when we started MySQL we skipped the user privileges table.

Next, instruct MySQL which database to use:

use mysql;

Reset Password

Enter the new password for the root user as follows:

update user set password=PASSWORD("mynewpassword") where User='root';

and finally, flush the privileges:

flush privileges;

Restart

Now the password has been reset, we need to restart MySQL by logging out:

quit

and simply stopping and starting MySQL.

On Ubuntu and Debian:

sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start

Solution 2

When I used this command:

update user set password=PASSWORD("mynewpassword") where User='root';

I have got the following error:

ERROR 1054 (42S22): Unknown column 'password' in 'field list'

I have searched for some time, and I found that we have to use authentication_string in the place of password, so I think the command should be:

update user set authentication_string=PASSWORD("mynewpassword") where User='root';

The second command works for me perfectly.

Share:
46,185

Related videos on Youtube

Sai Teja Nagamothu
Author by

Sai Teja Nagamothu

Updated on September 18, 2022

Comments

  • Sai Teja Nagamothu
    Sai Teja Nagamothu over 1 year

    I forgot my Phpmyadmin username and password.I have installed phpmyadmin very long back but I forgot those login details now what should I do to access back the phpmyadmin panel ?

  • Farzad Yousefzadeh
    Farzad Yousefzadeh over 8 years
    That actually helped a lot.
  • Amul Bhatia
    Amul Bhatia almost 6 years
    helped me, only thing i used 'authentication_string' instead of 'password'