Cannot reset MySQL server password even uninstalling everything

user1532587 asked:

i’m struggling with a shiny new ubuntu server. My MySQL root password is not working and I cannot change it.
What I’ve tried:

sudo service mysql stop
sudo mysqld_safe --skip-grant-tables &

mysql
use mysql;
UPDATE mysql.user SET authentication_string=PASSWORD('MYPASS') WHERE User='root';
FLUSH PRIVILEGES;
quit

sudo service mysql start

mysql -u root -p
Access denied for user 'root'@'localhost'

I’ve also tried with mysql_secure_installation but the same as before

Some additional info

➜  ~ cat /etc/lsb-release     
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS"

mysql  Ver 14.14

Even tried removing mysql-server and re installing

My answer:


Look for a saved password in /root/.my.cnf. Because you weren’t asked to give your password when you tried to connect to MySQL, a password is most likely saved there.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.