Mysql – Access denied for user ‘root’@’localhost’ (using password yes)

installationMySQLmysql-5.6

I was trying to install MySQL 5.6.15 to my computer and got this error:

unable to update security settings. access denied for user
'root'@'localhost' (using password yes)

I guess current root password is wrong but I do not remember what it was. So how can I fix this problem?

Best Answer

If you installed MySQL 5.6 from the command line, the easiest way to find the temporary password is to go to the Linux command line do the following:

cd
cat `ls -la | grep mysql | grep secret | awk '{print $9}'` | awk '{print $18}'

This will quickly print the temporary password.

Try to login using that password

cd
OLDPASSFILE=`ls -la | grep mysql | grep secret | awk '{print $9}'`
PASSWORD=`cat ${OLDPASSFILE} | awk '{print $18}'
mysql -uroot -p${PASSWORD}

If the temporary password is no longer available, then you will have do the following:

NEWPASS="whateveriwant"
service mysql stop
service mysql start --skip-grant-tables
mysql -ANe"update mysql.user set password=PASSWORD('${NEWPASS}') where user='root'"
service mysql restart

Give it a Try !!!