After you installed the cdr_mysql add-on (asterisk-addons), did you add load=cdr_addon_mysql.so entry to modules.conf and restart Asterisk? Also, don’t forget to create a mysql user account/password that matches the one in your cdr_mysql.conf when you create the cdr table in your new database. Here’s the script incase you don’t have it.
CREATE DATABASE asterisk;
GRANT INSERT
ON asterisk.*
TO asteriskaccount
IDENTIFIED BY 'asteriskpassword';
USE asterisk;
CREATE TABLE `cdr` (
`calldate` datetime NOT NULL default '0000-00-00 00:00:00',
`clid` varchar(80) NOT NULL default '',
`src` varchar(80) NOT NULL default '',
`dst` varchar(80) NOT NULL default '',
`dcontext` varchar(80) NOT NULL default '',
`channel` varchar(80) NOT NULL default '',
`dstchannel` varchar(80) NOT NULL default '',
`lastapp` varchar(80) NOT NULL default '',
`lastdata` varchar(80) NOT NULL default '',
`duration` int(11) NOT NULL default '0',
`billsec` int(11) NOT NULL default '0',
`disposition` varchar(45) NOT NULL default '',
`amaflags` int(11) NOT NULL default '0',
`accountcode` varchar(20) NOT NULL default '',
`userfield` varchar(255) NOT NULL default ''
);
ALTER TABLE `cdr` ADD INDEX ( `calldate` );
ALTER TABLE `cdr` ADD INDEX ( `dst` );
ALTER TABLE `cdr` ADD INDEX ( `accountcode` );
Hi
I already created a account with a password .
and they match with the file cdr_mysql.conf .
Is it the only think to change?
when I reload asterisk I got :
[color=green]
[app_directory.so] => (Extension Directory)
== Registered application ‘Directory’
[cdr_addon_mysql.so] => (MySQL CDR Backend)
== Parsing ‘/etc/asterisk/cdr_mysql.conf’: Found
Apr 19 11:57:21 WARNING[6707]: config.c:499 process_text_line: parse error: No category context for line 14 of cdr_mysql.conf
Apr 19 11:57:21 WARNING[6707]: cdr_addon_mysql.c:295 my_load_module: Unable to load config for mysql CDR’s: cdr_mysql.conf[/color]
And my cdr_mysql is like this :
[color=green]
;
; Note - if the database server is hosted on the same machine as the
; asterisk server, you can achieve a local Unix socket connection by
; setting hostname=localhost
;
; port and sock are both optional parameters. If hostname is specified
; and is not “localhost”, then cdr_mysql will attempt to connect to the
; port specified or use the default port. If hostname is not specified
; or if hostname is “localhost”, then cdr_mysql will attempt to connect
; to the socket file specified by sock or otherwise use the default socket
; file.
;
;[global]
hostname=localhost
dbname=asterisk
;table=cdr
password=
user=root
;port=3306
;sock=/var/lib/mysql/mysql.sock
;userfield=1[/color]
[cdr_addon_mysql.so] => (MySQL CDR Backend)
== Parsing ‘/etc/asterisk/cdr_mysql.conf’: Found
May 1 20:55:44 ERROR[371]: cdr_addon_mysql.c:438 my_load_module: Failed to connect to mysql database asteriskcdrdb on localhost.
Where does this script go?
CREATE DATABASE asterisk;
GRANT INSERT
ON asterisk.*
TO asteriskaccount
IDENTIFIED BY ‘asteriskpassword’;
USE asterisk;
CREATE TABLE cdr ( calldate datetime NOT NULL default ‘0000-00-00 00:00:00’, clid varchar(80) NOT NULL default ‘’, src varchar(80) NOT NULL default ‘’, dst varchar(80) NOT NULL default ‘’, dcontext varchar(80) NOT NULL default ‘’, channel varchar(80) NOT NULL default ‘’, dstchannel varchar(80) NOT NULL default ‘’, lastapp varchar(80) NOT NULL default ‘’, lastdata varchar(80) NOT NULL default ‘’, duration int(11) NOT NULL default ‘0’, billsec int(11) NOT NULL default ‘0’, disposition varchar(45) NOT NULL default ‘’, amaflags int(11) NOT NULL default ‘0’, accountcode varchar(20) NOT NULL default ‘’, userfield varchar(255) NOT NULL default ‘’
);
ALTER TABLE cdr ADD INDEX ( calldate );
ALTER TABLE cdr ADD INDEX ( dst );
ALTER TABLE cdr ADD INDEX ( accountcode );
my cdr_mysql.conf reads:
;
; Note - if the database server is hosted on the same machine as the
; asterisk server, you can achieve a local Unix socket connection by
; setting hostname=localhost
;
; port and sock are both optional parameters. If hostname is specified
; and is not “localhost”, then cdr_mysql will attempt to connect to the
; port specified or use the default port. If hostname is not specified
; or if hostname is “localhost”, then cdr_mysql will attempt to connect
; to the socket file specified by sock or otherwise use the default socket
; file.
;
[global]
hostname=localhost
dbname=asteriskcdrdb
table=cdr
password=
user=root
port=3306
sock=/tmp/mysql.sock
userfield=1