Skip to content

Instantly share code, notes, and snippets.

@Guley
Last active October 21, 2019 05:11
Show Gist options
  • Save Guley/5334a835cc9a8f9e486f167c3feba534 to your computer and use it in GitHub Desktop.
Save Guley/5334a835cc9a8f9e486f167c3feba534 to your computer and use it in GitHub Desktop.
For Ubuntu 18.04 and mysql version 14.14 Distrib 5.7.22 follow the below step to reset the mysql password.
Step 1
sudo systemctl stop mysql
Step 2
sudo systemctl edit mysql
This command will open a new file in the nano editor, which you'll use to edit MySQL's service overrides. These change the default service parameters for MySQL. This file will be empty, so add the following content:
[Service]
ExecStart=
ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid --skip-grant-tables --skip-networking
Step 3
sudo systemctl daemon-reload
sudo systemctl start mysql
Step 4
sudo mysql -u root
Step 5
FLUSH PRIVILEGES;
Step 6
UPDATE mysql.user SET authentication_string = PASSWORD('new_password') WHERE user = 'root';
Step 7
UPDATE mysql.user SET plugin ='mysql_native_password' WHERE user = 'root';
Step 8
GRANT permission ON database.table TO 'user'@'localhost';
Step 9
sudo systemctl revert mysql
and finally
sudo systemctl restart mysql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment