This question already has an answer here:

I'm just starting with MySQL (version 5.7.20 on Xubuntu 16.04), and in playing around with it I changed the root password. Now I can't log in as root -- I either forgot the password or didn't set it to what I thought I did. This is my home hobby system, so I'm the only user.

I may as well start over. But it's not clear to me how to do that. On Ubuntu there are about 9 or 10 mySQL packages involved, and I'm not sure I can uninstall all of them cleanly. I'm happy to just trash the database if I only knew the commands to start with a new one.

I could use some advice, preferably from someone who knows how it works on Ubuntu and it's variants, as these packages are managed by Canonical and are not necessarily like even the Debian ones.

marked as duplicate by Erik Darling, hot2use, mustaccio, LowlyDBA, RDFozz Jan 12 '18 at 15:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


See the manual. There is a 'simple' procedure for starting mysqld with --skip-grant-tables. This lets you in. Change the root password once you are in.

  • Like I said: newbie, at least in respect of MySQL. I came to this indirectly, following directions in stuff about Django, and I don't even remember where I learned to change the password. – 4dummies Jan 12 '18 at 14:02
  • It turns out I don't know how to restart mysqld, and it's not obvious (to me) how it normally starts. It's just up when I reboot. So I don't know how to restart it differently. Does anybody know how to untangle this on Ubuntu? – 4dummies Jan 12 '18 at 14:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.