Errors loading Asterisk addons, CDR(Call Detail Records) to MySQL

The other day I was doing an Asterisk 1.2 –> 1.4 upgrade.  I have a MySQL database that Asterisk records the Call Detail Record’s(CDR) too.  I deleted the asterisk 1.2 modules, then compiled/installed asterisk 1.4 & asterisk-addons 1.4.  Being that I hadn’t set up the CDR MySQL stuff in a while I loaded the res_mysql.conf, but I copied it from the cdr_addon.conf file by accident.  Because the two files have similer syntax It took me a while to figure this one out.  I checked all the passwords and I even checked the Asterisk CLI to see if the module loaded.  MySQL was populated with the same tables as before.  I also kept seeing this error (see below).

Possibly a mixed up addon file.

Possibly a mixed up addon file.

The error:

[Mar 15 03:25:44] ERROR[23793]: res_config_mysql.c:629 mysql_reconnect: MySQL RealTime: Failed to connect database server asterisk on  (err 2002). Check debug for more info.

The res_mysql & cdr_mysql have very similer config files, but you can’t ‘cut & paste’ between them.

Sample configuration for res_mysql.conf:

;dbhost =
;dbname = asterisk
;dbuser = myuser
;dbpass = mypass
;dbport = 3306
;dbsock = /tmp/mysql.sock

; Sample configuration for cdr_mysql.conf:


Be careful not to mix the two between upgrades!


  • I dont what your point is here?. You start by describing the error, which btw I am looking for a solution to it, but then you basically do not offer any solutions to it. You just say not to mix res_mysql.conf with cdr_mysql.conf….is that your big solution?

    Comment | September 14, 2009
  • mattb

    The error comes from bad syntax. My point is that many people will cut and paste between the two. Then they are confused when they see this error… If the config file is parsed with bad values you will not get a connection!

    If you followed my examples but still get the same error, it is likely caused by some other problem. perhaps the Asterisk addons package was not installed? Can you post your configs please?

    Comment | September 21, 2009

RSS feed for comments on this post. TrackBack URL

Leave a comment