A couple of months ago, I upgraded the MariaDB database server from 10.1 to 10.2 on my Ubuntu server without any problem. Everything worked without any issues.
A few days ago, I decided to log on to the database to create a new blank database for a new WordPress.
After running the standard sudo mysql -u root -p commands to gain access, I was met with the MariaDB Plugin ‘unix_socket’ is not loaded error. Whoa!
What’s the heck? I entered the root user’s correct password but couldn’t log on. So I quickly searched Google, and many help articles recommended bypassing MariaDB’s standard logon process and changing or resetting the root password.
This brief tutorial will show students and new users how to quickly and easily fix the MariaDB database server with the unix_socket is not loaded error.
There might be other methods out there that work. However, a quick fix might be just following the steps below:
Add Unix Authentication plugin to MariaDB Config
If this issue relates to the Unix authentication plugin, the quickest fix is to open the MariaDB configuration file, add a single line, and save. For example, run the commands below to open the MariaDB default configuration file.
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
Then add the line below the [mysqld] section.
plugin-load-add = auth_socket.so
After adding the line to the file, run the commands below to restart MariaDB.
sudo systemctl restart mariadb.service
Next, try to sign on to the database again.
sudo mysql -u root
Running the commands above should log on to the database without a password prompt. That’s because it’s using Unix socket authentication.
Change to Standard Authentication
Step 1 should be enough to get you into the MariaDB server. And should work as long as you keep using Unix socket authentication. However, other apps and services like phpMyAdmin that depend on standard password authentication will stop working when you enable socket authentication for the root user.
A typical error you’ll get when Unix socket authentication is used will be ERROR 1698 (28000): Access denied for user ‘root’@’localhost.’
So now that you’ve access to the database run the commands below to disable Unix socket authentication for the root user.
use mysql; update user set plugin='' where User='root'; flush privileges; exit
Exit out, and you’re done.
Now you should be able to log on to the server with standard password authentication.
That’s it!
Awesome! You saved my life.
You saved my life too!
Thank you very much !! <3
It worked perfectly! Thanks for sharing your experiences and the solution.
Thank you!!!
This did NOT work for me on Ubuntu 16.04.5 with Mariadb replacing Mysql … I can still only login at the command line after providing the password… Any tips? (Thanks for this how-to, in any case.)
I managed to resolve my problem (by the way, I’m using MariaDB 10.3). The unix socket plugin is enabled by default. BUT you may also need to log into MariaDB (with your password, for instance) and then execute:
ALTER USER root@localhost IDENTIFIED VIA unix_socket;
In my case, the unix socket authentication was installed and enabled, but my root user was not configure to use it yet… Hope this helps some poor, frustrated soul in the future…
Thank you very much!