Last active
March 8, 2018 09:21
-
-
Save vietdien2005/19c00dd72ad17754f9cd254433423ed2 to your computer and use it in GitHub Desktop.
reset password mysql
This file contains hidden or 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 | |
```bash | |
sudo /etc/init.d/mysql start | |
``` | |
# Make MySQL service directory & give MySQL user permission to write to the service directory. | |
```bash | |
sudo mkdir /var/run/mysqld && sudo chown mysql: /var/run/mysqld | |
``` | |
# Start MySQL manually, without permission checks or networking. | |
```bash | |
sudo mysqld_safe --skip-grant-tables --skip-networking & | |
``` | |
# Log in without a password. | |
```bash | |
mysql -uroot mysql | |
``` | |
# Update the password for the root user. | |
```sql | |
USE mysql; | |
update user set authentication_string=password('password') where user='root'; | |
flush privileges; | |
``` | |
# Turn off MySQL. | |
```bash | |
sudo /etc/init.d/mysql stop | |
``` | |
# Start the MySQL service normally. | |
```bash | |
sudo /etc/init.d/mysql start | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment