Last active
April 24, 2018 14:12
-
-
Save emamut/b0860ab5d95810bbbe70ff7715cd078c to your computer and use it in GitHub Desktop.
Reset MySQL 5 root password - Ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Stop MySQL | |
sudo service mysql stop | |
# Make MySQL service directory. | |
sudo mkdir /var/run/mysqld | |
# Give MySQL user permission to write to the service directory. | |
sudo chown mysql: /var/run/mysqld | |
# Start MySQL manually, without permission checks or networking. | |
sudo mysqld_safe --skip-grant-tables --skip-networking & | |
# Access to MySQL | |
mysql -u root | |
# Change mysql root password | |
update mysql.user set authentication_string=PASSWORD(""), plugin="mysql_native_password" where User='root'; | |
FLUSH PRIVILEGES; | |
EXIT | |
# Turn off MySQL. | |
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown | |
# Start the MySQL service normally. | |
sudo service mysql start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment