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
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock symbolic-links=0 log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid plugin-load-add=auth_socket.so
I then connected to MySQL using the auto-generated temporary root password and set the
root user to use
ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket; FLUSH PRIVILEGES;
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?