Skip to content

Instantly share code, notes, and snippets.

@vietdien2005
Last active March 8, 2018 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vietdien2005/19c00dd72ad17754f9cd254433423ed2 to your computer and use it in GitHub Desktop.
Save vietdien2005/19c00dd72ad17754f9cd254433423ed2 to your computer and use it in GitHub Desktop.
reset password mysql
# 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