Skip to content

Instantly share code, notes, and snippets.

@csymlstd
Created July 6, 2018 20:48
Show Gist options
  • Save csymlstd/b7d03213d83446961b9b70eaa661c785 to your computer and use it in GitHub Desktop.
Save csymlstd/b7d03213d83446961b9b70eaa661c785 to your computer and use it in GitHub Desktop.
Reset MySQL Password on Ubuntu 16.04
# Stop MySQL Service
sudo systmctl stop mysql
# Make service directory and give permission to mysql to write
sudo mkdir /var/run/mysqld
sudo chown mysqld: /var/run/mysqld
# Start MySQL manually
sudo mysqld_safe --skip-grant-tables --skip-networking &
# Login
mysql -uroot mysql
# Update the password
UPDATE mysql.user SET authentication_string=PASSWORD('NEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='localhost';
EXIT;
# Shutdown manual service
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
# Restart MySQL
sudo systemctl restart mysql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment