Skip to content

Instantly share code, notes, and snippets.

@pavankjadda
Created November 5, 2018 17:28
Show Gist options
  • Save pavankjadda/2a202b33d01085f4405891584dfd6e58 to your computer and use it in GitHub Desktop.
Save pavankjadda/2a202b33d01085f4405891584dfd6e58 to your computer and use it in GitHub Desktop.
MySQL Change password on Ubuntu when default password not provided

MySQL Change password on Ubuntu when default password not provided

  1. Open terminal and tyfollowing commands one by one. Do not close the terminal after you are done
sudo mysql
USE mysql;
UPDATE user SET authentication_string=PASSWORD('YOUR_PASSWORD') WHERE User='root';
UPDATE user SET plugin="mysql_native_password";
FLUSH PRIVILEGES;
quit;
  1. Open new terminal and try to login with the following commad
mysql -u root -p
<Enter your new password>
  1. If step 2 does not work, redo step1 on terminal1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment