Skip to content

Instantly share code, notes, and snippets.

@AjeetK
Created September 27, 2017 19:28
Show Gist options
  • Save AjeetK/a39260dbc72acd67711424a2bcf7095b to your computer and use it in GitHub Desktop.
Save AjeetK/a39260dbc72acd67711424a2bcf7095b to your computer and use it in GitHub Desktop.
Reset MySQL "root" User Password

How To Reset "root" User Password In MySQL

Following are the set of commands to be run to reset root user password:

# 1. Stop mysql process
> sudo service mysqld stop

# 2. Change user to mysql & run mysql process using --skip-grant-tables option
> sudo su - mysql
> /usr/sbin/mysqld --skip-grant-tables --skip-networking &

# 3. Login in mysql shell as root user & set the new password.
> mysql -u root
> flush privileges
> SET PASSWORD FOR root@'localhost' = PASSWORD('newpassword');
> quit
exit

# 4. Restart mysql process
> sudo service mysqld start

# 5. Now you can login using new password
> mysql -uroot -p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment