How to change MySQL’s root to use mysql_native_password in Ubuntu

After installing MySQL, log in to it via terminal with

$sudo mysql -u root

Once inside MySQL, we will need to change the default plugin authentication to mysql_native_password and set a password for root.

mysql> ALTER USER [email protected] IDENTIFIED WITH mysql_native_password BY 'password';
mysql> exit

You can now login in MySQL as root using the password you set.

$mysql -u root -p