我可以从centos 6.7上的命令行连接到mysql数据库:
mysql -u root -h 127.0.0.1 --protocol=TCP -p;此外:
mysql -u root -h localhost --protocol=TCP -p;但是,如果通过导入程序插件从运行在端口4567上的NodeBB连接,则会出现访问拒绝错误:
From a node application for importing data to the database I see:
22/11 09:11 [28144] - error: Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password: YES)
at Handshake.Sequence._packetToError (/var/www/nodebb/node_modules/nodebb-plugin-import-punbb2/node_modules/mysql/lib/protocol/sequences/Sequence.js:48:14)
at Handshake.ErrorPacket (/var/www/nodebb/node_modules/nodebb-plugin-import-punbb2/node_modules/mysql/lib/protocol/sequences/Handshake.js:101:18)
at Protocol._parsePacket (/var/www/nodebb/node_modules/nodebb-plugin-import-punbb2/node_modules/mysql/lib/protocol/Protocol.js:270:23)
at Parser.write (/var/www/nodebb/node_modules/nodebb-plugin-import-punbb2/node_modules/mysql/lib/protocol/Parser.js:77:12)
at Protocol.write (/var/www/nodebb/node_modules/nodebb-plugin-import-punbb2/node_modules/mysql/lib/protocol/Protocol.js:39:16)
at Socket.<anonymous> (/var/www/nodebb/node_modules/nodebb-plugin-import-punbb2/node_modules/mysql/lib/Connection.js:82:28)
at Socket.emit (events.js:107:17)
at readableAddChunk (_stream_readable.js:163:16)
at Socket.Readable.push (_stream_readable.js:126:10)
at TCP.onread (net.js:538:20)我尝试过在*.* to 'root'@'%'上授予特权(这是一个流浪者框),但是错误仍然存在。
有人能说出是什么原因造成的吗?我可以使用相同的凭据从同一个框上的简单nodejs脚本连接到MySQL,而不会出错。
SELinux被禁用:
sudo cat /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted发布于 2015-11-22 14:07:56
如果这是CentOS的默认安装,则应检查SELinux配置。SELinux为您的系统提供了细粒度的访问保护系统。这是由内核中的SELinux模块控制的。
由SELinux控制的任何访问都将由审计部门记录(默认安装为CentOS)。日志位于/var/log/audit/audit.log,应该有一些特定于MySQL访问尝试的条目。
默认情况下,在CentOS6上它被设置为强制。这是在/etc/sysconfig/selinux中配置的。更改后,需要重新启动。
您可以禁用SELinux,但最正确的方法是向SELinux添加策略,以允许从特定应用程序访问MySQL。您可以像在手册中解释的那样这样做。
https://serverfault.com/questions/738111
复制相似问题