# Asterisk with MySQL

**URL:** <https://community.asterisk.org/t/asterisk-with-mysql/32057>\
**Category:** Asterisk Support\
**Created:** [July 27, 2010, 10:12am UTC](https://community.asterisk.org/t/asterisk-with-mysql/32057 "2010-07-27T10:12:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/asterisk/original/2X/4/475d0c889911cfb84ac4881ad6df8b523e3f9105.png) [@system](https://community.asterisk.org/u/system)\
**Post date:** [July 27, 2010, 10:12am UTC](https://community.asterisk.org/t/asterisk-with-mysql/32057/1 "2010-07-27T10:12:49Z")

</div>

hello  
i was looking at documentation regarding how to bind asterisk with MySQL database  
i’m stuck at the point where i should create the tables. it starts with something like

CREATE TABLE `sip_buddies` (  
`id` int(11) NOT NULL auto\_increment,  
`name` varchar(80) NOT NULL default ‘’,

and so on

but i have no idea where should i write these lines, is it in a CLI? or should they be in a file proper to MySQL. if the latter, does anyone know which one is it?

thank you

---

<div class="post-metadata">

**Author:** ![MrFidget](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@MrFidget](https://community.asterisk.org/u/MrFidget)\
**Post date:** [July 27, 2010, 12:14pm UTC](https://community.asterisk.org/t/asterisk-with-mysql/32057/2 "2010-07-27T12:14:49Z")

</div>

That looks like SQL code to me. Thats the stuff you would type into the MySQL client.

Best way to do this is to put it into a text file and run the mysql client with input from the sql file.

For example:  
Create a text file. Something like: asterisk\_mysql\_table\_create.sql and put all of your mysql table setup stuff in there. Dont forget to put a “create database\_name;” and “use database\_name;” at the start of the file to set what database to create your tables in.

To run that file in mysql simply, from the command line type:

```auto
[root@mypbx ~] # [i]mysql -p < asterisk_mysql_table_create.sql[/i]
```

The -p will prompt you for a password if you have one for MySQL.

Have a look at some mysql getting started tutorials to get more of a feel for what you need to do.

Let us know how you go  
Cheers  
Chris

---

<div class="post-metadata">

**Author:** ![dereklinrs](https://avatars.discourse-cdn.com/v4/letter/d/aca169/32.png) [@dereklinrs](https://community.asterisk.org/u/dereklinrs)\
**Post date:** [July 27, 2010, 2:23pm UTC](https://community.asterisk.org/t/asterisk-with-mysql/32057/3 "2010-07-27T14:23:46Z")

</div>

hi,

you need to install the mysql addon and include other sip columns in the sip buddy table. you might find below link useful:  
[zonetel.com/forum/97/1/ShowPost.aspx](http://www.zonetel.com/forum/97/1/ShowPost.aspx)

best regards,  
derek

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/asterisk/original/2X/4/475d0c889911cfb84ac4881ad6df8b523e3f9105.png) [@system](https://community.asterisk.org/u/system)\
**Post date:** [July 27, 2010, 3:56pm UTC](https://community.asterisk.org/t/asterisk-with-mysql/32057/4 "2010-07-27T15:56:28Z")

</div>

hello  
thanks for your help  
in fact, i had no idea that i should run those commands in MySQL CLI  
so everything works perfect now, besides one thing:  
if i use the database to register sip users, the user registration is successful, i can make calls between users (the extensions are also extracted from the database), but whenever i try to use the MeetMe application, i get this error:

[Jul 27 17:35:41] WARNING[19859]: channel.c:3277 set\_format: Unable to find a codec translation path from 0x100 (g729) to 0x2 (gsm)  
[Jul 27 17:35:41] WARNING[19859]: file.c:992 ast\_streamfile: Unable to open conf-getpin (format 0x100 (g729)): No such file or directory

i ran some tests, and i can use the MeetMe application when extensions are located in the database, but as soon as i point my sip users to the database rather than sip.conf, i get this error  
any idea what could be the reason?

---

<div class="post-metadata">

**Author:** ![MrFidget](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@MrFidget](https://community.asterisk.org/u/MrFidget)\
**Post date:** [July 27, 2010, 9:38pm UTC](https://community.asterisk.org/t/asterisk-with-mysql/32057/5 "2010-07-27T21:38:32Z")

</div>

Codecs: You are running the free “passthough” version of the g729 codec and it wont convert to other codecs.

If you can get away with it, use ulaw (USA, Canada etc) or alaw (Europe. Aust, NZ etc). They take up 88K or so per channel as opposed to \< 32K per channel with overhead. That will probably solve part of your problem.

or

Buy some g729 licenses 😄

Let me know how you go  
Cheers  
Chris

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/asterisk/original/2X/4/475d0c889911cfb84ac4881ad6df8b523e3f9105.png) [@system](https://community.asterisk.org/u/system)\
**Post date:** [July 28, 2010, 8:21am UTC](https://community.asterisk.org/t/asterisk-with-mysql/32057/6 "2010-07-28T08:21:08Z")

</div>

hello, well i would have loved to buy the licenses but unfortunately that’s not an option for me now lol  
so i disallowed g729 from the available codecs, and everything works like a charm now, although i’m getting a warning saying:

[Jul 28 10:05:10] WARNING[22127]: channel.c:3277 set\_format: Unable to find a codec translation path from 0x8 (alaw) to 0x400 (ilbc)

but the call is being established without problems, so i guess i can ignore it 😒  
thanks again for your help

---

<div class="post-metadata">

**Author:** ![MrFidget](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@MrFidget](https://community.asterisk.org/u/MrFidget)\
**Post date:** [July 28, 2010, 11:41am UTC](https://community.asterisk.org/t/asterisk-with-mysql/32057/7 "2010-07-28T11:41:09Z")

</div>

use

```auto
dissalow=all
allow=ulaw 
```

or allow=alaw, depending on where you are. If you set that for each SIP node, you wont have any codec conversions.

Also, check the settings in your iax.conf, you may have some stuff in there. The error looks like you have an ilbc setting hidden somewhere. (maybe even h323 or mgcp)

But it does work. Thats the main thing 😃

Glad to have helped.  
Cheers  
Chris
