In this article, we will come to know how we can switch the MySQL root user default (Auth_Socket) authentication method to mysql_native_password.
-
Auth_socket Authentication
Auth_socket authentication is a server-side default authentication plugin that is used to authenticate the client input in order to access databases. Auth_Socket authentication plugin uses the SO_PEERCRED Unix socket option to obtain information about the user running the client program.
-
Mysql_native_password Authentication
The other authentication method is mysql_native_password authentication which is known as a traditional method to authenticate, it is not secure as Auth_socket authentication it uses just a hash of the password. This authentication method is not recommended for authentication.
The process to switch auth_socket to mysql_native_password:
First of all, check the current authentication method for this you can use the following command.
mysql> SELECT user, authentication_string,plugin,host FROM mysql.user;
To configure the root account to authenticate with a password, run the following ALTER USER command. Be sure to change the password to a strong password of your choosing
mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’
Now run the following command to flush the tables and implement new changes
mysql> FLUSH PRIVILEGES;
Now you can see we have changed the authentication method from auth_socket to mysql_native_password.