10

I'm trying to use dbd with mysql as authentification with Apache 2.4.

When Apache starts, i have this error :

[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>
[...]

If i change the password to put an invalid one, i received the exception

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

Debian : 7.8 Apache : 2.4.10 libapr1 : 1.5.1-3 (i tried to downgrade, but i cannot)

Note: The server do not have php nor php+mysql (libphpmysql) installed

Edit :

my.cnf (client part)

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

Edit (2) :

I also tried to use the "odbc" for mysql

odbc.ini :

dbd_mysql.conf

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

/etc/odbc.ini (i edited the config to remove sensitive data)

[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=

If i use :

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

It working perfectly.. but on the 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!

Edit (3) :

I found that i did not register the driver :

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

Then changed the "dbd_mysql.conf" with :

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

But still the same problem (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!
Joshua
  • 627
  • 4
  • 9
  • 21
  • Is mysql running and/or is that the correct location for the socket file? because apache's trying to use the socket file, while your config is trying to tell it to use a TCP connection. – Marc B May 12 '15 at 17:32
  • Mysql server is running on another server. I did not set any socket file.. – Joshua May 12 '15 at 17:38
  • well, apache's trying to connect via the socket, so something in your configuration is wrong. – Marc B May 12 '15 at 17:39
  • I posted the content of all the files i have modified. Do you have any idea where the configuration could be wrong ? – Joshua May 12 '15 at 17:42
  • no idea. but apache config can be spread across many many files. maybe there's another authnz module elsewhere that's doing its own connection. – Marc B May 12 '15 at 17:43
  • But i think it's might not be related to the "socket" thing.. because i would not of received the "access denied for user..." when i typed the wrong password. – Joshua May 12 '15 at 18:36
  • What does your my.cnf show? You might have `Skip-networking` enabled. You would need to comment that out. – Panama Jack May 13 '15 at 19:18
  • There is not reference to "skip-networking" in the my.cnf – Joshua May 14 '15 at 13:09
  • Is there a better place to post this kind of question?.. – Joshua May 19 '15 at 01:03

2 Answers2

4

DBDParams must be separated with comma: DBDParams param1=value1[,param2=value2] http://httpd.apache.org/docs/2.4/mod/mod_dbd.html

Alexander Ushakov
  • 5,139
  • 3
  • 27
  • 50
  • I changed the ";" to "," `DBDParams "DRIVER={MySQL ODBC 5.3 Driver},SERVER=192.168.1.2,DATABASE=MY_DATABASE,UID=MY_USER,PWD=MY_PASSWORD"`, still the same error : `Invalid DBD Parameters - open returned SQL_ERROR (-1)` – Joshua May 21 '15 at 12:44
  • My answer will help with your first case with `DBDriver mysql` In the second case it seems that dbd cant' find ODBC driver by given name. – Alexander Ushakov May 21 '15 at 12:53
  • Thanks, it works! configuration : `DBDriver mysql DBDParams "host=192.168.1.2,user=MY_USER,pass=MY_PASSWORD,dbname=MY_DATABASE" DBDMin 1 DBDKeep 1 DBDMax 10 DBDExptime 300 DBDPersist On` – Joshua May 21 '15 at 14:20
0

in my.conf try

[client]
protocol=tcp

The reference Connecting to the MySQL Server provides an explanation of how to override the default connection methodology.

The reference Using Option Files vaguely explains what values can be placed in the my.conf file. Essentially an argument that can be passed to the mysql command on the command line (ie. --protocol) can be specified, without the dashes, in the option file.

Chrissy
  • 1
  • 3