MySQL root changed password went wrong

MySQL

So basically this is what I did:

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set password=PASSWORD("~)<iXyyj<w!,s!\yZ%]YN#m;d") where User='root';
Query OK, 2 rows affected (0.01 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit

And now I can't access using that password. What did I do wrong? maybe the password isn't supposed to have special characters or something?

PS: centos 6.5

Best Answer

You may have to do the following

NEWROOTPASSWORD="Cha@g3m3"
service mysql restart --skip-grant-tables --skip-networking
SQL="update mysql.user SET password=PASSWORD('${NEWROOTPASSWORD}') WHERE user='root';"
mysql -ANe"${SQL}"
service mysql restart
mysql -uroot -p${NEWROOTPASSWORD}

If you get the mysql prompt, CONGRATULATIONS !!!

Then, go change the password properly. Don't use the exclamation point or semicolon for a password as they mean something to Linux.

MySQL Documentation for this situation: http://dev.mysql.com/doc/refman/5.6/en/resetting-permissions.html

Give it a Try !!!