In Ubuntu systems running MySQL 5.7 (and later versions), the root MySQL user is phối to tát authenticate using the auth_socket plugin by mặc định rather than thở with a password. This allows for some greater security and usability in many cases, but it can also complicate things when you need to tát allow an external program (e.g., phpMyAdmin) to tát access the user.
If you prefer to tát use a password when connecting to tát MySQL as root, you will need to tát switch its authentication method from auth_socket to tát mysql_native_password. source
Open up the MySQL prompt from your terminal:
$ sudo mysql
Next, kiểm tra 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 trương mục to tát authenticate with a password, lập cập the following ALTER USER
command. Be sure to tát change password to tát a strong password of your choosing:
mysql > ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Then, lập cập FLUSH PRIVILEGES
which tells the server to tát 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 tát 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.