Error message: Failed to connect database sever asterisk

Hi Everyone;

I have installed asterisk version 1.2.14, asterisk-addons 1.2.5 and mysql version 4.1.21. on Red Hat linux version 9.0. I created the database ‘asterisk’ in mysql so that the asterisk cdr record can be stored in my sql. I has edited the asterisk modules.conf to load cdr_addon_mysql.so and also change the configuration in cdr_mysql.conf. Finally, i do a reset on asterisk.

I got the below error message after i reset my asterisk.

Error [6825]: cdr_addon_mysql.c:231 mysql_log: cdr_mysql:cannot connect to database

ERROR[6969]: res_config_mysql.c: 651 mysql_reconnect: MYSQL RealTime: Failed to connect database server asterisk on (err 1045). Check debug for more info.

Do you have any solution on how to solve the above error message. Please Help !

Check to insure mysql is running

also you need to check the way you setup the DB.

did u create a user for it?? and give it full rights to the db
and why use asterisk db???
most common name used is asteriskcdrdb

Hi,

now that the DB is created, with the username and passwd specified in cdr_mysql.conf ,do in mysql:

grant all privileges on asteriskdb.* to username@localhost identified by ‘passwd’;
grant all privileges on asteriskdb.* to username@127.0.0.1 identified by ‘passwd’;
flush privileges;

or whatever you think is the correct prvileges(read, write, update,…)

also, if you enable debugging messages to the cli, (in logger.conf uncomment the correct line), then with asterisk -rvvvvvvvvvddddddddddddd, do a ‘reload cdr_addon_mysql.so’ then you will get more output

Hi;

Below is how I created the asteriskcdrdb database;
In the console, I type the following command;
a) cd /usr/local/mysql/bin
b) ./mysql --user=root --password=password -h dbhost
c) Mysql > CREATE DATABASE asteriskcdrdb;
d) Mysql > GRANT ALL PRIVILEGES
-> ON asteriskcdrdb.*
-> TO asterisk@localhost;
e) Mysql > use asteriskcdrdb;
f) Mysql > 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 ‘’
-> );

Asterisk side

a) Copy cdr_addon_mysql.so into /usr/lib/asterisk/modules/
b) Edit /etc/sterisk/cdr_mysql.conf and add the following lines:

[global] 
hostname=localhost 
dbname=asteriskcdrdb 
;password=password 
user=asterisk 
;port=3306 
;sock=/tmp/mysql.sock 
;userfield=1 

I do not set any password for my database

c) Edit /etc/existing_etc_asterisk/cdr_mysql.conf and add the following lines:
[global]
Hostname= localhost
Dbname= asteriskcdrdb
User= asterisk

c)Edit /etc/asterisk/modules.conf and add the following line inside the modules section:
Load => cdr_addon_mysql.so

Adding Libraries path

  1. Open the console and type “gedit /etc/profileâ€

Does the MySQL database acknowldge the user “Asterisk” as a valid user account?

: O )

I see you have a database and your using root as the account to create that… but nowhere do I see you creating the user account along with the privliages invovled.

Can’t have one without the other.