In some MySQL installation in Ubuntu. You cannot login as root because it is not configured to use mysql_native_password. In this post, I will teach you how to enable mysql_native_password.

Log in to MySQL 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 root@localhost IDENTIFIED BY 'password';
mysql> exit

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

mysql -u root -p