In Ubuntu systems running MySQL 5.7 (and later versions), the root MySQL user is set to authenticate using the auth_socket plugin by default rather than with a password. This allows for some greater security and usability in many cases, but it can also complicate things when you need to allow an external program (e.g., phpMyAdmin) to access the user.
If you prefer to use a password when connecting to MySQL as root, you will need to switch its authentication method from auth_socket to mysql_native_password.
source
Open up the MySQL prompt from your terminal:
$ sudo mysql
Next, check which authentication method each of your MySQL user accounts use with the following command:
mysql > SELECT user,authentication_string,plugin,host FROM mysql.user;
You will see that the root user does in fact authenticate using the auth_socket plugin. To configure the root account to authenticate with a password, run the following ALTER USER
command. Be sure to change password to a strong password of your choosing:
mysql > ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Then, run FLUSH PRIVILEGES
which tells the server to reload the grant tables and put your new changes into effect:
mysql > FLUSH PRIVILEGES;
Check the authentication methods employed by each of your users again to confirm that root no longer authenticates using the auth_socket plugin:
mysql > SELECT user,authentication_string,plugin,host FROM mysql.user;
You will see in output that the root MySQL user now authenticates using a password.