Skip to content

Instantly share code, notes, and snippets.

@Majunko
Last active June 13, 2019 16:28
Show Gist options
  • Save Majunko/4d25eb40e150e77701e74b44120155c0 to your computer and use it in GitHub Desktop.
Save Majunko/4d25eb40e150e77701e74b44120155c0 to your computer and use it in GitHub Desktop.
reset root password MySQL 5.7

This is a common error in Ubuntu when you install MySQL and phpMyAdmin, you can not log in into phpMyAdmin. So this is the solution:

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 &

Log in without a password

mysql -uroot mysql

Update the password for the root user

UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root';
EXIT;

Turn off MySQL

sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown

Start the MySQL service normally

sudo service mysql start

source: https://coderwall.com/p/j9btlg/reset-the-mysql-5-7-root-password-in-ubuntu-16-04-lts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment