j9btlg
Last Updated: April 23, 2019
·
58.67K
· fluxsauce

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

13 Responses
Add your response

29190

Thousand thanks!!! It really helped me!

over 1 year ago ·
29280

Hey,

just signed up here to be able to comment here.

Thanks for the post, this really saved me today. I only had to replace '%' with 'localhost' because I only had the root created with "localhost" ability. After that, I could login and add the root-user as well for "%" (any host) and now I can connect easily and add other users.
Thanks again, I already gist'ed it ;)

over 1 year ago ·
29664

I could get in my precious MySQL after resetting this this command (for ubuntu 17.10 and mysql-5.7 the command on the post didn´ t work)

UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='localhost';
over 1 year ago ·
29696

Saved the day!
Thanks @morhook, mine couldn't recognize '%' too

over 1 year ago ·
29848

@moelha @morhook @ebumstengel @Jan Sarman could have used `UPDATE mysql.user SET authenticationstring=PASSWORD('YOURNEWPASSWORD'), plugin='mysqlnativepassword' WHERE User='root'` to update all root passwords regardless of their host.

11 months ago ·
30773

https://quickensupports.org/quicken-canada-support/ visit here for more details about quicken software.

7 months ago ·
30844

I have recently downloaded Ubuntu on my pc but after that, my printer doesn't work. it shows no printer driver installed. I uninstalled the driver and again install the driver on my pc. then I visit https://www.canonprintersupportnumbers.com/blog/how-to-fix-canon-printer-error-code-b200/ and found the solution.

7 months ago ·
31776

Hey! it's a really helpful code I try to in my system. https://www.hpsupport365.com/blog/how-to-fix-hp-printer-in-error-state-windows-10/

3 months ago ·
31879

Thanks for this information. In case of any tech help contact geek squad tech support

about 2 months ago ·
31913

Thank you, sir

Thank you for sharing the important information we have shared with people and we hope from God that God will get your longevity.
Awesome information and totally on point! It was exactly the information I was searching for and now have a clear understanding of how to start making money with your tube. I get

easily frustrated when searching for needed information, I find that there are gaps in information or it's not explained properly and for some reason, I get the feeling that it has been told

like that on purpose with the intent to keep me searching and searching and searching only to get no real answers to my questions all the while spending way too much of my

valuable time for nothing. But this information was real and I appreciated it so so very much, Thank you! https://bit.ly/2FEwJbF

about 2 months ago ·
32236

This is an awesome post thank you for sharing this interesting post, Visit web:- https://emailsupporthelplinenumber.us/

28 days ago ·
32237

This is an awesome post thank you for sharing this interesting post,
Web:- https://printersupporthelplinenumber.us/

28 days ago ·
32651

If the problem still persists, call Canon Helpline or a printer technician to prevent further printer damage.
https://www.canonprintersupport247.com/blog/how-to-fix-canon-printer-error-code-b200/

2 days ago ·