Skip to content

Instantly share code, notes, and snippets.

@voidnerd
Last active August 24, 2021 07:59
Show Gist options
  • Select an option

  • Save voidnerd/12ca252263412bedfdf3bb8fa7f5bb23 to your computer and use it in GitHub Desktop.

Select an option

Save voidnerd/12ca252263412bedfdf3bb8fa7f5bb23 to your computer and use it in GitHub Desktop.
reset mysql (5.7) root password on ubuntu 19.04

Step 1

sudo /etc/init.d/mysql stop

Step 2

sudo mkdir /var/run/mysqld/
sudo chown mysql /var/run/mysqld/

sudo mysqld_safe --skip-grant-tables &

Step 3

mysql -uroot

step 4

use mysql;

update user set authentication_string=PASSWORD("mynewpassword") where User='root';

flush privileges;

quit

Step 5

sudo /etc/init.d/mysql stop
sudo killall mysqld mysqld_safe
sudo /etc/init.d/mysql start

Step 6

login now

mysql -u root -p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment