How to Fix MariaDB Plugin unix_socket, login error
What is the Unix_Socket Plugin?
The Error “Plugin ‘unix_socket’ is not loaded” is commonly seen on Ubuntu 15.04/15.10/16.04 . This tutorial shows how to fix it.
The Unix_Socket authentication plugin, which allows users to use OS credentials to connect to MariaDB via Unix socket, is first supported in MariaDB 5.2.0. This plugin is not installed by default.
Log into MariaDB monitor.
mysql -u root -p
Then install the Unix_Socket plugin with this command:
MariaDB [(none)]> install plugin unix_socket soname 'auth_socket';
My Ubuntu system has a user named root, so I create a MariaDB user root identified via the unix_socket plugin.
MariaDB [(none)]> create user linuxbabe identified via unix_socket;
MariaDB [(none)]> quit
And now I can log into MariaDB monitor as user linuxbabe without typing password because I already logged into Ubuntu system as linuxbabe.
That’s how Unix_Socket authentication plugin works.
Fix Plugin ‘unix_socket’ is not loaded Error
The Unix_Socket authentication plugin only works when your Linux OS and MariaDB have a user account with the same username.
Your Linux OS has a root user. MariaDB also has a root user. So sometimes, when you try to log into MariaDB monitor as root user, MariaDB may authenticate you via the Unix_Socket plugin but this plugin is not installed by default. So you see Plugin ‘unix_socket’ is not loaded Error.
Another authentication plugin is mysql_native_password. MariaDB uses this plugin to authenticate a user who is created with this command:
create user demo_user@localhost identified by password 'secret_password';
To fix the above error, we can tell MariaDB to use mysql_native_password plugin to authenticate root user.
First stop MariaDB. If you have installed MariaDB from Ubuntu repository, use this command to stop it.
sudo systemctl stop mysql
If you have installed MariaDB from MariaDB repository, use the following command to stop it.
sudo systemctl stop mariadb
Then start MariaDB with –skip-grant-tables option which bypass user authentication.
sudo mysqld_safe --skip-grant-tables &
Next, log into MariaDB monitor as root.
mysql -u root
Enter the following SQL statement to check which authentication plugin is used for root.
MariaDB [(none)]> select Host,User,plugin from mysql.user where User='root';
You might see it’s using unix_socket plugin. To change it to mysql_native_password plugin, execute this command:
MariaDB [(none)]> update mysql.user set plugin='mysql_native_password';
If you forgot the MariaDB root user password, you can also change the root password now with the following command:
MariaDB [(none)]> update mysql.user set password=PASSWORD("newpassword") where User='root';
Exit MariaDB monitor.
flush privileges; quit;
sudo kill -9 $(pgrep mysql)
Start MariaDB again.
sudo systemctl start mysql or sudo systemctl start mariadb
Now you can use normal password to login.
mysql -u root -p
I hope this article helped you to fix Plugin ‘unix_socket’ is not loaded error.