I have forget my MySQL root password and not able to login in phpMyAdmin. I am very bad in MySQL commandline. After long struggle while Googling, I found this solution in Stackoverflow -
But this will work only latest Ubuntu version because of enhance security of MySQL.
First, as root, stop the mysql server.
systemctl stop mysql
mkdir -p /var/run/mysqld
chown mysql:mysql /var/run/mysqld
/usr/sbin/mysqld --skip-grant-tables --skip-networking &
jobs
Leave that terminal running and open another terminal, not as root.
Now access MySQL database without password:
mysql -u root -p
mysql>
FLUSH PRIVILEGES;
mysql> USE mysql;
mysql> UPDATE user SET authentication_string=PASSWORD("LKYbak0r") WHERE User='root';
mysql> UPDATE user SET plugin="mysql_native_password" WHERE User='root';
mysql> exit
pkill mysqld
jobs
Lastly, start MYSQL database:
systemctl start mysql
mysql -u root -p
Source: Stackoverflow