j9btlg
Last Updated: May 05, 2017
·
1.117K
· fluxsauce
E5529d996db3f33b95a95a28e7a1b923  1

Reset the MySQL 5.7 root password in Ubuntu 16.04 LTS

This is a bit gnarly. If you have a better method of updating the password without triggering a warning about PASSWORD being deprecated, I'm all ears.

# 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' AND Host='%';
EXIT;
# Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
# Start the MySQL service normally.
sudo service mysql start
Say Thanks
Respond
Filed Under