1 => Create a temporary SQL text file,
/tmp/temp.sql
2 => Open
/tmp/temp.sql file and write below query
SET PASSWORD FOR root@localhost = PASSWORD('New_password');
3 =>
Add below line in your MySQL config file (on Ubuntu this is on /etc/mysql/my.cnf
), under the [mysqld]
section: init-file=/tmp/temp.sql
4 > Now restart MySQL service after that check your mysql password has been reset
5 => Now remove the
init-file=/tmp/temp.sql
entry from my.cnf
(do not forget this). Even as the server is up and running.6 : => Remove the
/tmp/temp.sql
file.Note : you can use this step for xampp also just use /opt/lampp/etc/my.cnf
###################Enjoy ##########################