Recover lost MySQL password
Try the below:


Add below 2 lines in my.cnf

skip-grant-tables
skip-networking

Restart mysql service

service mysqld restart


Note: if you don't have a service, you can do from /etc/init.d/
Connect mysql:

mysql

Update root password:

UPDATE mysql.user 
SET PASSWORD=PASSWORD('MyNewPass') 
WHERE USER='root'; 

flush privileges"; 
exit;

Remove newly added lines from my.cnf and restart the mysql service.


Permission errors mean you don't have admin permission where you are trying to do the task, so login with admin login first.