Step 1: Add Unix Authentication Plugin To MariaDB Config
If this issue relates to Unix authentication plugin, the quickest fix is to open MariaDB configuration file and add a single line into the file and save. Run the commands below to open MariaDB default configuration file.
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
Then add the line below [mysqld] section.
plugin-load-add = auth_socket.so
After adding the line into 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 logon onto the database without password prompt… that’s because it’s using unix socket authentication.
Step 2: Change To Standard Authentication
Step 1 should be enough to get you into 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 being 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 logon to the server with standard password authentication.
That’s it!