Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Ubuntu 18.04 - Set MySQL Root Password

When installing MySQL on Ubuntu 18.04, it no longer prompts for you to set a password. After having performed the installation, the only way to log in is with:

sudo mysql

There are many ways to set a root password in MySQL, but this is the only way that appears to work.

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'myPasswordHere';

Now you can log in as you usually did, with:

mysql -u root -p

References

Last updated: 14th January 2019
First published: 14th January 2019