After installing Ubuntu 18.04 and using tasksel to install mysql, it doesn’t ask for the password anymore. This is because of the change in the authentication module of the root user by default in MySQL. To get it back to the old system i.e. native mysql password you need to perform the following steps:

1. SELECT user,authentication_string,plugin,host FROM mysql.user; 

You will see output like

| user             | authentication_string                     | plugin                | host      |
| root             |                                           | auth_socket           | localhost |
| mysql.session    | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys        | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *CC744277A401A7D25BE1CA89AFF17BF607F876FF | mysql_native_password | localhost |
4 rows in set (0.00 sec)

2. Verify that the root user is using auth_socket plugin.

3. Run the following command to set the new password

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

That’s all is required to run MySQL like before.

Configure MySQL root password in Ubuntu 18.04

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.