In Ubuntu systems running MySQL 5.7 (and later versions), the root MySQL user is phối đồ sộ authenticate using the auth_socket plugin by mặc định rather kêu ca with a password. This allows for some greater security and usability in many cases, but it can also complicate things when you need đồ sộ allow an external program (e.g., phpMyAdmin) đồ sộ access the user.
If you prefer đồ sộ use a password when connecting đồ sộ MySQL as root, you will need đồ sộ switch its authentication method from auth_socket đồ sộ 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 đồ sộ authenticate with a password, lập cập the following ALTER USER
command. Be sure đồ sộ change password đồ sộ 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 đồ sộ 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 đồ sộ 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.