# Asterisk Project : MySQL CDR Backend

Added by mdavenport , edited by rnewton on Jan 25, 2013

##### ODBC

Using MySQL for CDR records is supported by using ODBC and the cdr_adaptive_odbc module (depends on res_odbc).

The below cdr_mysql module has been deprecated in 1.8.

##### Native

Alternatively, there is a native MySQL CDR module.

To use it, configure the module in cdr_mysql.conf. Create a table called cdr under the database name you will be using the following schema.

    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 '',
            uniqueid varchar(32) NOT NULL default '',
            userfield varchar(255) NOT NULL default ''
    );

##### In 1.8 and later

The following columns can also be defined:

            peeraccount varchar(20) NOT NULL default ''
            linkedid varchar(32) NOT NULL default ''
            sequence int(11) NOT NULL default '0'