Connecting to external mySQL dB?

I read:
voip-info.org/wiki/view/Asterisk+cmd+MYSQL
then
voip-info.org/wiki/index.php … isk-addons

I did that all except “You must have MySQL installed and the development package”. I dont want MySQL on my asterisk server since im accessing an external mySQL dB. Is thier a reason I still need it on thier to be able to do this?
I put this in the dial plan
exten => 904,1,MYSQL(Connect connid 192.168.3.33 root password test)
and get this in the cli
[Jan 2 21:31:23] WARNING[26380]: pbx.c:1797 pbx_extension_helper: No application ‘MYSQL’ for extension (internal, 904, 1)

hi
plz check with following command in Asterisk console "show applications’
& check in application list MYSQL application is included or not . also check asterisk module module directory.
as CLI logs shows ur MYSQL application not install on Asterisk

Amit

The message is clear, if you want to build the mysql addon stuff you must have mysql and mysql development packages installed but you don’t have to run the mysql server on your box, just have it installed.

Cheers.

Marco Bruni

man what a pain in the but linux is.
ill keep working until i get it right…i got mysql installed still having problesm…

ok i spent my night reformatting, installing Centos 5 and asterisk.
I used the mysql that was in Centos 5.

[root@localhost ~]# rpm -qa | grep mysql
mysql-connector-odbc-3.51.12-2.2
libdbi-dbd-mysql-0.8.1a-1.2.2
mysql-5.0.22-2.2.el5_1.1
mysql-server-5.0.22-2.2.el5_1.1

localhost*CLI> show applications
-= Registered Asterisk Applications =-
MP3Player: Play an MP3 file or stream
MusicOnHold: Play Music On Hold indefinitely
NBScat: Play an NBS local stream

It still does not show MYSQL as being installed in the CLI…
so it looks like i need the mysql-devel still correct?

I really dont want to do:
voip-info.org/wiki/index.php … isk-addons
and screw stuff up unless Im sure about this…

thanks for any help!

CustomGT: I have faith in you :wink:. In order to use MySQL with asterisk you need the add-ons. They are not hard to compile just do:
wget URL_FOR_ADD_ONS_PACKAGE_THAT_YOU_WANT
tar -zxvf package_name
cd /package folder
make clean
make
make install

and then just restart asterisk.

Also I personally use AGI’s for PHP so I can run some other logic(/code) in php. I think that is more of a personal preference.

Hey Dovid, already did this:

wget downloads.digium.com/pub/asteris … ent.tar.gz

tar -zxf asterisk-addons-1.4-current.tar.gz

cd /usr/src/asterisk/asterisk-addons-1.4.5

Edited ‘Makefile’ and insert a line ‘ASTCFLAGS+=-DMYSQL_LOGUNIQUEID’ after the ‘ASTCFLAGS+=-fPIC’ line
make clean
./configure
make
make install

restarted asterisk

and it still doesnt show up with 'show applications’
I have not done this below part::

You must also have the DBD::mysql perl module installed!! Ensure your root@localhost user does not have a password then run the following:
perl -MCPAN -e "install DBD::mysql"
You can then apply your root@localhost password again (or make sure that you have an empty password for root, but be aware…)

@CustomGT, you should check if you have installed the development files of the mysql package, the package should be named something like mysql-dev, then rebuild the mysql addon package.

@Dovid, I agree with you, to me too php and phpagi are the best tools to work with an sql database server, I use the mysql addon just to store the cdr records in a mysql database.

Cheers.

Marco Bruni

mbruni:
Great minds think alike :wink:

[quote=“mbruni”]@CustomGT, you should check if you have installed the development files of the mysql package, the package should be named something like mysql-dev, then rebuild the mysql addon package.

@Dovid, I agree with you, to me too php and phpagi are the best tools to work with an sql database server, I use the mysql addon just to store the cdr records in a mysql database.

Cheers.

Marco Bruni[/quote]

Awesome thanks for the advice I got it to show up now in the cli. I think I have finally passed that Linux newbie stage, and it feels great. It really limits your asterisk abilities if you dont know it.
PHP is so easy for mysql if im in windows, because im an advanced windows user. In linux its a little harder for me still, but ill be working with it soon for the reasons you stated. For what im doing that MYSQL cmd is simpler.

Ill post back on my results with it.

Thanks again guys.

;Pull account information
exten => 904,1,MYSQL(Connect connid 192.168.3.33 root password testdb)
exten => 904,n,GotoIf($["${connid}" = “”]?error,1)

exten => error,1,NoOp(Connection Error - do whatever we have to do to crash nicely!)
exten => error,n,Hangup

Ok i got the above in my dialplan…when I dial 904, this happens on the cli:

-- Executing [904@internal:1] MYSQL("SIP/102-b7614958", "Connect connid 192.168.3.33 root password testdb") in new stack

[Jan 4 20:53:38] WARNING[3268]: app_addon_sql_mysql.c:234 aMYSQL_connect: mysql_real_connect(mysql,192.168.3.33,root,dbpass,testdb,…) failed

192.168.3.33 is the IP of my laptop, not my asterisk server. I can run PHP page on my laptop to connect to the MYSQL with host of ‘localhost’ and connect to the db and run queries so I know it works. (i mean i got apache/php/mysql on my laptop and I can run PHP pages with mysql queries…) Maybe the laptop is not allowing the asterisk server to access the mysql dB?

It takes a long time for the second line to come up also, I assume it is timing out…

Very Possible. I would check from another PC to see if you can connect to your laptop and get in to mysql. It could be a permissions issue in mysql.

I loaded the php page up on a differnet computer, that worked. Then I realized that the mySQL is done server side duh.

What things can I use to connect to the dB? All I can think of is Excel.
Any other quick simple ways of testing it?

Thanks

Have a look at mysql_ping: il2.php.net/mysql_ping

thanks for the help. I didnt get to use this as it was for linux and I didnt have any linux computers around.

I did get it to work tho! For future readers:
I used a computer at another location. So at the location with the mysql db I had to open up a port in the dsl modem to forward to the mysql db.
Then I had to edit the my.ini file (my.conf in linux i think), i basicly uncommented out the information and put in my information.

Then I had to go into phpmyadmin and add the computer that was outside the network to the permissions. It then allowed me to connect, and I ran my first mysql command on asterisk.

Thier was a syntax error in my string but at least it tried to run it, ill look at that later tonite hopefully…

thanks for the help, this is one project almost done that i have been working on for a few weeks

exten => 904,1,MYSQL(Connect connid 192.168.3.33 root password test)
exten => 904,n,MYSQL(Query resultid ${connid} SELECT\ *\ FROM\ accounts\ WHERE\ acctno=1111)
exten => 904,n,MYSQL(Fetch fetchid ${resultid} acctno name amount date); fetch row
exten => 904,n,NoOp(Acct No = ${acctno})
exten => 904,n,NoOp(Name = ${name})
exten => 904,n,NoOp(Amount = ${amount})
exten => 904,n,NoOp(Date = ${date})
exten => 904,n,MYSQL(Clear ${resultid})
exten => 904,n,MYSQL(Disconnect ${connid})
exten => 904,n,Hangup

Here is a basic query I did, its tested and works for anyone looking for help on MYSQL cmd. The wiki helped some but they always try to do too advanced things with the examples…

You dont need all mysql server, you just need mysql client and dev

[quote=“CustomGT”];
192.168.3.33 is the IP of my laptop, not my asterisk server. I can run PHP page on my laptop to connect to the MYSQL with host of ‘localhost’ and connect to the db and run queries so I know it works. (i mean i got apache/php/mysql on my laptop and I can run PHP pages with mysql queries…) Maybe the laptop is not allowing the asterisk server to access the mysql dB?

It takes a long time for the second line to come up also, I assume it is timing out…[/quote]

do you have the ‘%’ in the Mysql.users database? Maybe your mysql server accepts connection from mysql only, so you have to add the ip of your asterisk server or you can use %

[quote=“vctor”][quote=“CustomGT”];
192.168.3.33 is the IP of my laptop, not my asterisk server. I can run PHP page on my laptop to connect to the MYSQL with host of ‘localhost’ and connect to the db and run queries so I know it works. (i mean i got apache/php/mysql on my laptop and I can run PHP pages with mysql queries…) Maybe the laptop is not allowing the asterisk server to access the mysql dB?

It takes a long time for the second line to come up also, I assume it is timing out…[/quote]

do you have the ‘%’ in the Mysql.users database? Maybe your mysql server accepts connection from mysql only, so you have to add the ip of your asterisk server or you can use %[/quote]

I fixed all this already. mySQL wasnt accepting connections from other hosts besides localhost. I had to edit my.ini (windows) then go into phpmyadmin and give permissions to the hosts trying to connect to the mySQL database.

lemens-ts.com