<div class="gmail_quote">On Tue, Oct 25, 2011 at 7:30 AM, bilal ghayyad <span dir="ltr">&lt;<a href="mailto:bilmar_gh@yahoo.com">bilmar_gh@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Dear Tark;<br>
<br>
The asterisk version I am running is 1.8 and I can select mysql from menuselect when I am compiling.<br>
<br>
But when I googled for cdr-mysql, I discovered that I have to login for mysql and create the database and run a script to create this and give the grants. All what I found in google is related to other asterisk versions, while mine is 1.8, so the problem is how to know the required script to create the database and give the right grants to be used for CDR that suite the version I am running? From where I can get this?<br clear="all">
<br></blockquote><div><br><br>The following script will generate an &quot;asterisk&quot; database with a table named &quot;CDR&quot; that will work with asterisk 1.8.  Be sure to change &#39;PASSWORD&#39; with whatever password you want to use.<br>
<br><code>
</code><pre>SET SQL_MODE=&quot;NO_AUTO_VALUE_ON_ZERO&quot;;
CREATE DATABASE `asterisk` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `asterisk`;</pre>
<pre>CREATE TABLE IF NOT EXISTS `cdr` (
`recid` mediumint(8) unsigned NOT NULL auto_increment COMMENT &#39;Record ID&#39;,
`calldate` datetime NOT NULL default &#39;0000-00-00 00:00:00&#39;,
`clid` varchar(80) NOT NULL default &#39;&#39;,
`src` varchar(80) NOT NULL default &#39;&#39;,
`dst` varchar(80) NOT NULL default &#39;&#39;,
`dcontext` varchar(80) NOT NULL default &#39;&#39;,
`channel` varchar(80) NOT NULL default &#39;&#39;,
`dstchannel` varchar(80) NOT NULL default &#39;&#39;,
`lastapp` varchar(80) NOT NULL default &#39;&#39;,
`lastdata` varchar(80) NOT NULL default &#39;&#39;,
`duration` int(11) NOT NULL default &#39;0&#39;,
`billsec` int(11) NOT NULL default &#39;0&#39;,
`disposition` varchar(45) NOT NULL default &#39;&#39;,
`amaflags` int(11) NOT NULL default &#39;0&#39;,
`accountcode` varchar(20) NOT NULL default &#39;&#39;,
`uniqueid` varchar(32) NOT NULL default &#39;&#39;,
`userfield` varchar(255) NOT NULL default &#39;&#39;,
PRIMARY KEY  (`recid`),
KEY `calldate` (`calldate`),
KEY `dst` (`dst`),
KEY `accountcode` (`accountcode`),
KEY `src` (`src`),
KEY `disposition` (`disposition`),
KEY `uniqueid` (`uniqueid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;</pre>
<pre>CREATE USER &#39;asterisk&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;PASSWORD&#39;;
GRANT FILE ON * . * TO &#39;asterisk&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;PASSWORD&#39; WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
GRANT INSERT ON `asterisk`.`cdr` TO &#39;asterisk&#39;@&#39;localhost&#39;;</pre><br>If you&#39;re going to be running the mysql database on the same server as the asterisk box, the following cdr_mysql.conf should also work for 1.8:<br>
<br><code>[global]<br>
hostname=localhost<br>
dbname=asterisk<br>
table=cdr<br>
password=PASSWORD<br>
user=asterisk<br>
port=3306<br>
sock=/var/lib/mysql/mysql.sock<br>
userfield=1<br>
loguniqueid=yes<br><br></code></div></div><br>-- <br>Thanks,<br>--Warren Selby, dCAP<br><a href="http://www.selbytech.com" target="_blank">http://www.SelbyTech.com</a><br><br>