How to reset forgotten password phpmyadmin in Ubuntu

In the latest version of MySQL Database Server, the password field of user table has been removed so the newest way with old server compatibility is given below. Just follow the instruction as follows it works for me.

Start the mysql server:

   sudo service mysql start

Now, go to sock folder:

   cd /var/run

Back up the socket:

   sudo cp -rp ./mysqld ./mysqld.bak

Stop server:

   sudo service mysql stop

Restore the socket:

   sudo mv ./mysqld.bak ./mysqld

Start mysqld_safe:

    sudo mysqld_safe --skip-grant-tables --skip-networking &

Initialize mysql shell:

    mysql -u root

Change password:

Here, we have to choose the database first

   mysql> use mysql;

And then show the tables:

    mysql> show tables;

You will find the user table, now let's see its fields:

    mysql> describe user;

If there is no field named 'password' and the password field is named ' authentication_string'. So, just do this:

   mysql> update user set authentication_string=password('newpwd') where user='root';

    mysql> update user set plugin="mysql_native_password" where User='root';

If there is a field named 'password' then do like this otherwise skip this:

    UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';

Now, hope everything will have ok.

   mysql> flush privileges;

    mysql> quit;

For checking:

   mysql -u root -p

done!

You can also check hostname/phpmyadmin 

 

I post my answer at stackoverflow

  • 249
  • 308
  • By Bablu Ahmed
  • Posted 11 months ago