I recently replaced an installation of MariaDB on a CentOS 7 server with MySQL Community Edition 5.7. The previous installation was configured to allow socket peer authentication for the root user, and I attempted to replicate that same setup with the new installation.

After reinstalling MySQL and re-initializing the database directory (/var/lib/mysql), I enabled the auth_socket plugin in /etc/my.cnf:





I then connected to MySQL using the auto-generated temporary root password and set the root user to use auth_socket:

ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket;

After making this change, when I attempt to connect to the database with sudo mysql -u root, I get an "access denied" error:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

I'm also unable to log in with the temporary password that worked before I updated the user.

Is there some subtle configuration step that I could be missing?


Assuming that you restarted the server after the changes to the cnf-File you could try to add the second line in the .cnf so that the server fails if the plugin does not initialize successfully:


This way you may be able to narrow the problem down. Or you could try to register the plugin at runtime from within mysql:

INSTALL PLUGIN auth_socket SONAME 'auth_socket.so';
| improve this answer | |

I cannot comment above answer, so here my "own" answer:

INSTALL PLUGIN auth_socket SONAME 'auth_socket.so';

doesn't work, at least not with MariaDB (5.5) on CentOS 7. For Mariadb, it should read:

INSTALL PLUGIN unix_socket SONAME 'auth_socket.so'; 

(see documentation here https://mariadb.com/kb/en/library/authentication-plugin-unix-socket/

Afterwards, do a

update user set plugin = 'unix_socket' where user='root'; 

restart mariadb, and login can be without password for user root (e.g. for crontab backups)

| improve this answer | |
  • That looks like it probably would fix it. Unfortunately, I'm not working on the project that prompted this question anymore, so I can't confirm the solution, but it would make sense based on the docs. – blm768 Nov 16 '18 at 6:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.