How to Fix MariaDB Plugin ‘unix_socket’ is not loaded Error

The Error “Plugin ‘unix_socket’ is not loaded” is commonly seen on Ubuntu 15.04/15.10/16.04 and any derivative distributions such as Linux Mint 18. This tutorial shows how to fix it.

What is the Unix_Socket Plugin?

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 linuxbabe, so I create a MariaDB user linuxbabe identified via the unix_socket plugin.

MariaDB [(none)]> create user linuxbabe identified via unix_socket;

Exit out of MariaDB monitor.

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.

mariadb unix_socket plugin

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';

Plugin 'unix_socket' is not loaded

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;

Stop mysqld_safe

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. Comments, questions or suggestions are always welcome. If you found this post useful, ? please share it with your friends on social media! Stay tuned for more tutorials.

Rate this tutorial
[Total: 39 Average: 4.9]

8 Responses to “How to Fix MariaDB Plugin ‘unix_socket’ is not loaded Error

  • Wayand Bahramzy
    7 years ago

    hi,

    After running this command:

    sudo mysqld_safe –skip-grant-tables

    when I try to run “sudo mysql -u root”

    still get this:..ERROR 1524 (HY000): Plugin ‘unix_socket’ is not loaded

    • Xiao Guo-An (Admin)
      7 years ago

      Make sure MariaDB service is stopped. If you have installed MariaDB from Ubuntu repository, then use this command to stop it.

      sudo systemctl stop mysql

      If you have installed MariaDB from MariaDB repository, then use the following command to stop it.

      sudo systemctl stop mariadb

      You can check its status with

      systemctl status mysql

      or

      systemctl status mariadb

      I didn’t explain this in my article until now. Hope that didn’t confuse you. BTW, you don’t need to add sudo when logging into MariaDB.

      • Wayand Bahramzy
        7 years ago

        hi again and thnx, its working now, but What is difference between these to plugins:
        unix_socket and mysql_native_password.

        why mysql_native_password is working and unix_sockets is not ?

        thnx once agian for your time.

        • Xiao Guo-An (Admin)
          7 years ago

          As I explained in the article, the unix_socket plugin allows you to use your Linux OS username to log into MariaDB. But this plugin is not installed by default. So it won’t work. mysql_native_password is the traditional authentication method.

  • Nuno Morais Sarmento
    6 years ago

    Thank you very much for again sharing a very useful tutorial, this time you have save me a lot a time I was getting nuts with phpmyadmin login error.

  • PHILEMON SUNDAY
    5 years ago

    Linuxbabe you finally solved an issue i was browsing the internet for hours. Thank you very much!!!!!!!

  • Thanks! Clearest explanation I’ve found.

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here