December 1, 2022

How to change Mysql authentication method from auth_socket to mysql_native_password

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

mysql> FLUSH PRIVILEGES;

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

Written by Sushanth, personal technology columnist and founder of Logical Bee. You can follow him on the social web or sign up for the email newsletter for your daily dose of how-to guides and video tutorials.



0 Comments: