MySQL Recover from lost root password Set root password, enable root user for socket and http access

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

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


Got any MySQL Question?