- Stop mysql Service
sudo systemctl stop mysql
tep by step instructions:
- Start off by stopping the MySQL service:
sudo systemctl stop mysql - Now, we need to restart the MySQL service but without password privileges being granted. Note that the
&at the end of the command just runs the service in the background and will allow us to continue using the current terminal.
sudo mysqld_safe --skip-grant-tables & - You’ll now be able to connect to the MySQL server as root, without specifying a password:
mysql -u root - Now, reset the root password, but first flush the privileges to reload the grants:mysql>
FLUSH PRIVILEGES;
mysql> use mysql;
mysql> update user set plugin=“mysql_native_password“ where User=’root‘;
mysql> ALTER USER ‚root’@’localhost‘ IDENTIFIED BY ’new_password_here‘;
mysql> FLUSH PRIVILEGES;
mysql> quit; - Finally, shut down the MySQL service and start it back up.$ sudo systemctl restart mysql