How to change Mysql authentication method from auth_socket to mysql_native_password

December 01, 2022 ・0 comments

In this article, we will see how we can change 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';

Query OK, 0 rows affected (0.00 sec)

Now run the following command to flush the tables and implement new changes


Query OK, 0 rows affected (0.00 sec)

Now you can see we have changed the authentication method from auth_socket to mysql_native_password

Post a Comment

If you can't commemt, try using Chrome instead.