MySQL

Recover from lost root password

Set root password, enable root user for socket and http access

Solves problem of: access denied for user root using password YES Stop mySQL:

sudo systemctl stop mysql

Restart mySQL, skipping grant tables:

sudo mysqld_safe --skip-grant-tables

Login:

mysql -u root

In SQL shell, look if users exist:

select User, password,plugin FROM mysql.user ;

Update the users (plugin null enables for all plugins):

update mysql.user set password=PASSWORD('mypassword'), plugin = NULL WHERE User = 'root';
exit;

In Unix shell stop mySQL without grant tables, then restart with grant tables:

sudo service mysql stop
sudo service mysql start

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow