Mysql database connection errors/warnings

Hi all,
Firstly, i am running * business ed., 1.2.9. I made changes to cdr_mysql.conf to fit my environment, and moved it to the /etc/asterisk and input tables into database and placed the following in the extconfig.conf:

sipusers => mysql,asteriskcdrdb,cdr
sippeers => mysql,asteriskcdrdb,cdr

but I still get these error/warnings when running asterisk:

[] => (MySQL RealTime Configuration Driver)
Jun 20 21:28:00 ERROR[7413]: res_config_mysql.c:615 mysql_reconnect: MySQL RealTime: Failed to connect database server on . Check debug for more info.
Jun 20 21:28:00 WARNING[7413]: res_config_mysql.c:450 load_module: MySQL RealTime: Couldn’t establish connection. Check debug.
Jun 20 21:28:02 ERROR[7413]: cdr_addon_mysql.c:437 my_load_module: Failed to connect to mysql database asteriskcdrdb on localhost.

Thanks for the help in advance.

The extconfig looks fine. Just out of interest why is the table called CDR?? Should that not be for your CDR data. Check your res_mysql.conf file. It is trying to connect to Mysql on your local machine, check the username and password is correct. Make sure that the username has rights to that database.

Firstly, i want to say thanks for your prompt response. Actually the cdr data is basically testing data as i attempt to get mysql up and running of which i will remove once the system is flawless w.r.t mysql. And yes, of course, the database username and password is correct but I did also check it from the command line just to ensure.

Also, I am not sure where the file is that connectsmysql which should look something like: $asteriskcdrdb = mysql_pconnect($hostname_localhost, $username_user, $password_password) or trigger_error(mysql_error(),E_USER_ERROR).

any more info in the debug log ? if you’re not including debug, you’ll need to modify logger.conf to include it, and then at the CLI issue a logger reload

Thanks for the logger.conf info: This is the report from the log:
Jun 21 04:43:11 VERBOSE[11660] logger.c: []Jun 21 04:43:11 VERBOSE[11660] logger.c: [] => (MySQL RealTime Configuration Driver)
Jun 21 04:43:11 DEBUG[11660] res_config_mysql.c: MySQL RealTime Host:
Jun 21 04:43:11 DEBUG[11660] res_config_mysql.c: MySQL RealTime Port: 0
Jun 21 04:43:11 DEBUG[11660] res_config_mysql.c: MySQL RealTime User:
Jun 21 04:43:11 DEBUG[11660] res_config_mysql.c: MySQL RealTime Password:
Jun 21 04:43:11 ERROR[11660] res_config_mysql.c: MySQL RealTime: Failed to connect database server on . Check debug for more info.

I suppose the mysql database connection application is in res_config.mysql.c which is in /usr/src/addons… and it is calling the variables, so… I am confused because the above log states the variable data is not being transfered. :confused:
Here is a copy of the res_mysql.conf:

dbhost = localhost
dbname = asterisk
dbuser = username
dbpass = password
dbport = 3306
dbsock = /tmp/mysql.sock

username, password changed for confidentiality. Thanks in advance for assistance.

In your res_mysql.conf

Your dbname should = asteriskcdrdb which you specified in extconfig.

Should look like this

dbhost = localhost
dbname = asteriskcdrdb <----
dbuser = username
dbpass = password
dbport = 3306
dbsock = /tmp/mysql.sock

This should work. If that is the correct database name. Must match the database specified in extconfig.

the file that goes with extenconfig.conf is a different file which is called cdr_mysql.conf I was just showing as a sample the other file because someone had asked about res_mysql.conf. The db is proplery named in cdr_mysql.conf.

cdr_mysql.conf file:
Thanks though.

Well then why are you pointing your sippeers and sipusers to that database??? An example is

sipusers => mysql,asterisk,sip_user
sippeers => mysql,asterisk,sip_peers

The CDR is totally different. The CDR will connect to the database in the cdr_mysql.conf. For the sipusers and sippeers you are telling it to use the Asteriskcdrdb in the extconfig but in the res_mysql you are telling Asterisk to connect to the Asterisk database. So its 2 different database’s. So the sippeers and sipusers is not finding the asteriskcdrdb database becuase you have told it to connect to Asterisk database. Hope this makes sense. Make sure the database is there and the table structure is correct.

Maybe I am off the plot abit here. Maybe this will not even solve your problem.

Hi again,
let’s take res_mysql.conf totally out of the picture. I am not using it, it was for illustration purposes only. I am only testing the connection and am actually using the cdr. Database already made for both, but i am only using asteriskcdrdb at this time which also has tables. (again, this is merely testing to get my database up and running) The reason I am doing this is because I noticed that my database was never connecting in the first place. And is still not connecting. Also, I would receive another type of error if it was not finding just not finding the db (i.e. db not found) but there is literally no connection at all. I am now wondering if I need to get the driver from the respository but I am not sure of where to go. Please, I am familiar with db and hostname for mysql.

However, are you saying that I am to use res_mysql.conf and cdr_mysql.conf and name both db the same. I was actually only trying to call one or the other. I am new to asterisk so is this what you are saying? Anyway, i tried that and it did not work either and gave both files the same db information…

Here is an example of my res_mysql file.

dbhost = localhost
dbname = asterisk
dbuser = root
dbpass = root
dbport = 3306
dbsock = /var/lib/mysql/mysql.sock

Try and locate the location of your mysql.sock file.

Oooohhh yeah–that’s what i’m talking about --mysql.sock incorrect directory. That was it. Thanks, thanks…

Glad you got it working…