大网数据广告活动
服务器运维问答

MySQL rejects connections with auth_socket

· 52CE 我爱测

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 th…

问题原文

原帖链接 · blm768 · CC BY-SA 3.0

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:

[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 auth_socket:

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?

社区高分解答

原帖链接 · sdittmar · CC BY-SA 4.0

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:

plugin-load-add=auth_socket.so
auth_socket=FORCE_PLUS_PERMANENT

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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-04-06)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。