Apache dbd内部错误:AH00629:无法连接到mysql

时间:2015-05-12 17:31:52

标签: mysql apache basic-authentication dbd

我正在尝试使用dbd和mysql作为Apache 2.4的身​​份验证。

当Apache启动时,我有这个错误:

[Tue May 12 13:07:18.789021 2015] [mpm_event:notice] [pid 10625:tid 140410697815936] AH00489: Apache/2.4.10 (Debian) configured -- resuming normal operations
[Tue May 12 13:07:18.789118 2015] [core:notice] [pid 10625:tid 140410697815936] AH00094: Command line: '/usr/sbin/apache2'
[Tue May 12 13:07:18.789469 2015] [dbd:error] [pid 10628:tid 140410697815936] (20014)Internal error: AH00629: Can't connect to mysql: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
[Tue May 12 13:07:18.789560 2015] [dbd:error] [pid 10628:tid 140410697815936] (20014)Internal error: AH00633: failed to initialise
[Tue May 12 13:07:18.790282 2015] [dbd:error] [pid 10629:tid 140410697815936] (20014)Internal error: AH00629: Can't connect to mysql: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
[Tue May 12 13:07:18.790441 2015] [dbd:error] [pid 10629:tid 140410697815936] (20014)Internal error: AH00633: failed to initialise
[Tue May 12 13:07:18.792481 2015] [dbd:crit] [pid 10628:tid 140410697815936] (20014)Internal error: AH00636: child init failed!
[Tue May 12 13:07:18.792595 2015] [dbd:crit] [pid 10629:tid 140410697815936] (20014)Internal error: AH00636: child init failed!

dbd_mysql.conf:

DBDriver mysql
DBDParams "host=192.168.1.2 port=3306 user=MY_USERNAME pass=MY_PASSWORD dbname=MY_DATABASE"
DBDMin  2
DBDKeep 4
DBDMax  10
DBDExptime 300
DBDPersist On

000-default.conf

[...]
DBDParams "dbname=DATABASENAME"
<IfModule authnz_ldap_module>
    <Directory /var/www/test/>
        AuthName "Authentication"
        AuthType Basic
        AuthBasicProvider dbd
        AuthDBDUserPWQuery "SELECT SHA2(password, 256) AS password FROM users WHERE username = %s"
        require valid-user
    </Directory>
</IfModule>
[...]

如果我更改密码以设置无效密码,我收到了例外

Internal error: AH00629: Can't connect to mysql: Access denied for user...

Debian:7.8 Apache:2.4.10 libapr1:1.5.1-3(我试图降级,但我不能)

注意:服务器没有安装php或php + mysql(libphpmysql)

编辑:

my.cnf(客户端部分)

[client]
port            = 3306
socket          = /var/run/mysqld/mysqld.sock

编辑(2):

我还尝试将“odbc”用于mysql

odbc.ini:

dbd_mysql.conf

DBDriver odbc
DBDParams "datasource=MYSERVER_MYSQL_MYDATABASE"
DBDMin  1
DBDKeep 1
DBDMax  10
DBDExptime 300

/etc/odbc.ini(我编辑了配置以删除敏感数据)

[MYSERVER_MYSQL_MYDATABASE]
Driver=/usr/local/lib/libmyodbc5a.so
Description=MYSERVER_MYSQL_MYDATABASE
SERVER=192.168.1.2
PORT=
USER=MY_USER
Password=MY_PASSWORD
Database=MY_DATABASE
OPTION=3
SOCKET=

如果我使用:

# isql MYSERVER_MYSQL_MYDATABASE
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+

它工作得很好..但是在apache error.log上:

[Thu May 14 09:07:51.323638 2015] [mpm_event:notice] [pid 1605:tid 140068309481344] AH00489: Apache/2.4.10 (Debian) configured -- resuming normal operations
[Thu May 14 09:07:51.323725 2015] [core:notice] [pid 1605:tid 140068309481344] AH00094: Command line: '/usr/sbin/apache2'
[Thu May 14 09:07:51 2015] [dbd_odbc] Invalid DBD Parameters - open returned SQL_ERROR (-1) at /tmp/buildd/apr-util-1.5:1146
[Thu May 14 09:07:51.323827 2015] [dbd:error] [pid 1608:tid 140068309481344] (20014)Internal error: AH00629: Can't connect to odbc: [dbd_odbc] Invalid DBD Parameters - open returned SQL_ERROR (-1) at /tmp/buildd/apr-util-1.5:1146
[Thu May 14 09:07:51.323870 2015] [dbd:error] [pid 1608:tid 140068309481344] (20014)Internal error: AH00633: failed to initialise
[Thu May 14 09:07:51 2015] [dbd_odbc] Invalid DBD Parameters - open returned SQL_ERROR (-1) at /tmp/buildd/apr-util-1.5:1146
[Thu May 14 09:07:51.324332 2015] [dbd:error] [pid 1609:tid 140068309481344] (20014)Internal error: AH00629: Can't connect to odbc: [dbd_odbc] Invalid DBD Parameters - open returned SQL_ERROR (-1) at /tmp/buildd/apr-util-1.5:1146
[Thu May 14 09:07:51.324430 2015] [dbd:error] [pid 1609:tid 140068309481344] (20014)Internal error: AH00633: failed to initialise
[Thu May 14 09:07:51.331767 2015] [dbd:crit] [pid 1608:tid 140068309481344] (20014)Internal error: AH00636: child init failed!
[Thu May 14 09:07:51.331823 2015] [dbd:crit] [pid 1609:tid 140068309481344] (20014)Internal error: AH00636: child init failed!

编辑(3):

我发现我没有注册驱动程序:

./myodbc-installer -d -a -n "MySQL ODBC 5.3 Driver" -t "DRIVER=/usr/local/lib/libmyodbc5a.so"

然后使用:

更改了“dbd_mysql.conf”
DBDriver odbc
DBDParams "CONNECT='DRIVER={MySQL ODBC 5.3 Driver};SERVER=192.168.1.2;DATABASE=MY_DATABASE;UID=MY_USER;PWD=MY_PASSWORD;'"
DBDMin  1
DBDKeep 1
DBDMax  10
DBDExptime 300

但仍然是同样的问题(error.log):

[Fri May 15 09:38:31.905733 2015] [core:notice] [pid 5215:tid 140452627486592] AH00094: Command line: '/usr/sbin/apache2'
[Fri May 15 09:38:31 2015] [dbd_odbc] Invalid DBD Parameters - open returned SQL_ERROR (-1) at /tmp/buildd/apr-util-1.5:1146
[Fri May 15 09:38:31.905842 2015] [dbd:error] [pid 5218:tid 140452627486592] (20014)Internal error: AH00629: Can't connect to odbc: [dbd_odbc] Invalid DBD Parameters - open returned SQL_ERROR (-1) at /tmp/buildd/apr-util-1.5:1146
[Fri May 15 09:38:31.905888 2015] [dbd:error] [pid 5218:tid 140452627486592] (20014)Internal error: AH00633: failed to initialise
[Fri May 15 09:38:31 2015] [dbd_odbc] Invalid DBD Parameters - open returned SQL_ERROR (-1) at /tmp/buildd/apr-util-1.5:1146
[Fri May 15 09:38:31.906424 2015] [dbd:error] [pid 5219:tid 140452627486592] (20014)Internal error: AH00629: Can't connect to odbc: [dbd_odbc] Invalid DBD Parameters - open returned SQL_ERROR (-1) at /tmp/buildd/apr-util-1.5:1146
[Fri May 15 09:38:31.906528 2015] [dbd:error] [pid 5219:tid 140452627486592] (20014)Internal error: AH00633: failed to initialise
[Fri May 15 09:38:31.915211 2015] [dbd:crit] [pid 5218:tid 140452627486592] (20014)Internal error: AH00636: child init failed!
[Fri May 15 09:38:31.915578 2015] [dbd:crit] [pid 5219:tid 140452627486592] (20014)Internal error: AH00636: child init failed!

2 个答案:

答案 0 :(得分:4)

DBDParams必须用逗号隔开:DBDParams param1=value1[,param2=value2] http://httpd.apache.org/docs/2.4/mod/mod_dbd.html

答案 1 :(得分:0)

在my.conf中尝试

[client]
protocol=tcp

引用Connecting to the MySQL Server提供了有关如何覆盖默认连接方法的说明。

引用Using Option Files含糊地解释了my.conf文件中可以放置哪些值。基本上可以在命令行中传递给mysql命令的参数(即.protocol)可以在选项文件中指定,而不是破折号。