How to reset MySQL root password in Ubuntu in latest Ubuntu versions 18.04 and above
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 mysqlmkdir -p /var/run/mysqldchown mysql:mysql /var/run/mysqld/usr/sbin/mysqld --skip-grant-tables --skip-networking &jobsLeave that terminal running and open another terminal, not as root.
Now access MySQL database without password:
mysql -u root -pmysql>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> exitpkill mysqldjobsLastly, start MYSQL database:
systemctl start mysqlmysql -u root -pSource: Stackoverflow
