# Failed to connect to MySQL in Asterisk real time

**URL:** <https://community.asterisk.org/t/failed-to-connect-to-mysql-in-asterisk-real-time/46160>\
**Category:** Asterisk Support\
**Created:** [May 14, 2014, 1:06pm UTC](https://community.asterisk.org/t/failed-to-connect-to-mysql-in-asterisk-real-time/46160 "2014-05-14T13:06:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![crazymoonboy](https://avatars.discourse-cdn.com/v4/letter/c/ee59a6/32.png) [@crazymoonboy](https://community.asterisk.org/u/crazymoonboy)\
**Post date:** [May 14, 2014, 1:06pm UTC](https://community.asterisk.org/t/failed-to-connect-to-mysql-in-asterisk-real-time/46160/1 "2014-05-14T13:06:50Z")

</div>

Hi,

Asterisk Version: 11.9  
Ubuntu Server: 14.04

I installed MySQL, Asterisk and additional softwares. I am able to logging into Asterisk and res\_config\_mysql.so file is located in “/usr/lib/asterisk/modules” folder. Also, mysqld.sock file is also located in “/var/run/mysqld/mysqld.sock” folder.

When I enter “realtime mysql status” at CLI, it is giving the below message:

ERROR[11973]: res\_config\_mysql.c:1577 mysql\_reconnect: MySQL RealTime: Failed to connect database server asterisk on /var/run/mysqld/mysqld.sock (err 1045). Check debug for more info.

I am wondering about the problem. I don’t understand why it is not connecting, even though everything is installed and configured properly.

Any help would be appreciated.

Thanks in Advance.

Regards,  
Mouli

---

<div class="post-metadata">

**Author:** ![abw1oim](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@abw1oim](https://community.asterisk.org/u/abw1oim)\
**Post date:** [May 14, 2014, 3:26pm UTC](https://community.asterisk.org/t/failed-to-connect-to-mysql-in-asterisk-real-time/46160/2 "2014-05-14T15:26:34Z")

</div>

Are You sure the credentials as well as the complete confuguration in res\_config\_mysql.conf is correct ?  
What happens if You issue the following at the linux command prompt:

mysql -u -p

where , and are the values associated with the configuration options in res\_config\_mysql.conf.

---

<div class="post-metadata">

**Author:** ![crazymoonboy](https://avatars.discourse-cdn.com/v4/letter/c/ee59a6/32.png) [@crazymoonboy](https://community.asterisk.org/u/crazymoonboy)\
**Post date:** [May 14, 2014, 6:04pm UTC](https://community.asterisk.org/t/failed-to-connect-to-mysql-in-asterisk-real-time/46160/3 "2014-05-14T18:04:54Z")

</div>

Hi,

Thanks for your reply. I found the solution.

Solution:

I added the DB details in general section in top of the res\_config\_mysql.conf file and forgot to comment the [general] in the bottom of the res\_config\_mysql.conf file 😄

So, it is ignoring the actual DB details which I have mentioned at the top of the file. Now, I commented out the bottom [general], and it is working fine now.

Thank you.

Regards,  
Mouli.
