FATAL ERROR DB Error: connect failed

30 posts / 0 new
Last post
vegastech
vegastech's picture
FATAL ERROR DB Error: connect failed

Receiving this error message when I try to access the web GUI

------------------------------
FATAL ERROR
DB Error: connect failed
Trace Back
/var/www/html/admin/libraries/db_connect.php:63 die_freepbx()
[0]: DB Error: connect failed
/var/www/html/admin/bootstrap.php:98 require_once()
[0]: /var/www/html/admin/libraries/db_connect.php
/etc/freepbx.conf:9 require_once()
[0]: /var/www/html/admin/bootstrap.php
/var/www/html/index.php:18 include_once()
[0]: /etc/freepbx.conf
------------------------------

* outbound calls are working
* used the FreePBX 2.210.62-2 distro for install
* system has been running fine for weeks
* I've looked at http://www.freepbx.org/forum/freepbx/general-help/fatal-error-db-error-connect-failed which I think is most of the answer - i.e. the MySQL login is bad so things aren't working
* the end of my /etc/amportal.conf shows
#
AMPDBUSER=freepbxuser
#
AMPDBPASS= ,,hashed password??,,
#
AMPDBHOST=localhost
#
AMPDBNAME=asterisk
#
AMPDBENGINE=mysql
#
datasource=
#
AMPENABLEDEVELDEBUG=

I think if I can login as root to MySQL I can reset the freepbxuser password. So any ideas how? I tried logging in with the freepbxuser and the password listed but that did not work.

Does anyone know if that is a real password or a hashed password?

Does FreePBX have a default mysql password? I don't recall setting a MySQL password during install.

vegastech
vegastech's picture
Big ol' WTF

Big ol' WTF

Now for some unknown reason everything is working fine. I can access the web GUI just fine. On the last reboot as I saw the mysqld fail on boot, did it just decide to work all of a sudden? Were files mangled and it retrieved some backup files?

sanjayws
sanjayws's picture
Err..don;t think its that

Err..don;t think its that smart :S

But yea, it is as seen, a mysql issue.

vegastech
vegastech's picture
It looks like MySQL said it

It looks like MySQL said it couldn't start, then fixed itself through saved data and transaction logs, then Asterisk's auto-restart function kicked it off successfully.

Can anyone confirm this theory? - I don't even know how to run a select statement without looking it up.

vegastech
vegastech's picture
MySQL errors are back

Staff said they could not log into there voicemail. Since I was not convinced the server had a clean brain from earlier I restarted it. Now I get an endless

Asterisk died with code 1

The Asterisk service shows it is dead. I did find the following link that points to a MySQL issue.

http://elastix.org/index.php/en/component/kunena/3-help/106592-asterisk-died-with-code-1-after-power-outage.html

Essentially, they say to run an auto-repair on MySQL. I like this idea but again I'm stymied by the basics.

- Does anyone know if that is a real password or a hashed password? I think it must be hashed since it does not seem to let me in.

- Does FreePBX have a default mysql password?

vegastech
vegastech's picture
Now I know

Now I know

I was trying the following command

mysqlcheck -uroot -p --auto-repair asteriskcdrdb cdr

I needed to use

mysqlcheck -ufreepbxuser -p --auto-repair asteriskcdrdb cdr

the password in /etc/amportal.conf is NOT hashed. My bad was using that password as the root password. Once I ran the correct command I saw a warning stating

asteriskcdrdb.cdr
warning : Table is marked as crashed
error : Size of datafile is: 647168 Should be: 647284
error : Corrupt

Repairing tables
asteriskcdrdb.cdr
info : Found block that points outside data file at 647152
status : OK

After that the Asterisk service restarted on its own - I'm guessing that's to be expected since it seemed it was on an endless loop of trying to start Asterisk then failing then trying to restart.

vegastech
vegastech's picture
So does anyone know if that

So does anyone know if that is the only db I need to auto-repair? Granted the system is up and running again but I would rather be proactive than have another issue in a day or two.

vegastech
vegastech's picture
There must be more to do,

There must be more to do, staff still can't access their voicemails. Argh.

tm1000
tm1000's picture
Yes you need to repair the

Yes you need to repair the 'asterisk' db as well

Senior Developer
Schmoozecom, INC

vegastech
vegastech's picture
So would I run

So would I run

mysqlcheck -ufreepbxuser -p --auto-repair asterisk cdr

to repair it? Not sure what the cdr at the end is for - still looking through MySQL docs online.

vegastech
vegastech's picture
So I ran

So I ran

mysqlcheck -ufreepbxuser -p --auto-repair asterisk

and was rewarded with the following that shows everything OK. I then tried her voicemail and still no-go. If you enter in the wrong password it will prompt you for the correct one. If you enter in the correct password it just sits there for 10 seconds then hangs up.

Is there a 'voicemail' db that I should run auto-repair on?

output:
asterisk.admin OK
asterisk.ampusers OK
asterisk.announcement OK
asterisk.backup OK
asterisk.backup_cache OK
asterisk.backup_details OK
asterisk.backup_items OK
asterisk.backup_server_details OK
asterisk.backup_servers OK
asterisk.backup_template_details OK
asterisk.backup_templates OK
asterisk.callback OK
asterisk.cidlookup OK
asterisk.cidlookup_incoming OK
asterisk.cronmanager OK
asterisk.custom_destinations OK
asterisk.custom_extensions OK
asterisk.dahdi OK
asterisk.daynight OK
asterisk.devices OK
asterisk.directory_details OK
asterisk.directory_entries OK
asterisk.disa OK
asterisk.extensions OK
asterisk.fax_details OK
asterisk.fax_incoming OK
asterisk.fax_users OK
asterisk.featurecodes OK
asterisk.findmefollow OK
asterisk.freepbx_log OK
asterisk.freepbx_settings OK
asterisk.globals OK
asterisk.iax OK
asterisk.iaxsettings OK
asterisk.incoming OK
asterisk.isymphony_conference_rooms OK
asterisk.isymphony_location OK
asterisk.isymphony_queues OK
asterisk.isymphony_users OK
asterisk.ivr_details OK
asterisk.ivr_entries OK
asterisk.language_incoming OK
asterisk.languages OK
asterisk.manager OK
asterisk.meetme OK
asterisk.miscapps OK
asterisk.miscdests OK
asterisk.module_xml OK
asterisk.modules OK
asterisk.notifications OK
asterisk.outbound_route_patterns OK
asterisk.outbound_route_sequence OK
asterisk.outbound_route_trunks OK
asterisk.outbound_routes OK
asterisk.outroutemsg OK
asterisk.paging_autoanswer OK
asterisk.paging_config OK
asterisk.paging_groups OK
asterisk.parkinglot OK
asterisk.phpagiconf OK
asterisk.pinset_usage OK
asterisk.pinsets OK
asterisk.queueprio OK
asterisk.queues_config OK
asterisk.queues_details OK
asterisk.recordings OK
asterisk.ringgroups OK
asterisk.setcid OK
asterisk.sip OK
asterisk.sipsettings OK
asterisk.sysadmin_options OK
asterisk.sysadmin_update_log OK
asterisk.timeconditions OK
asterisk.timegroups_details OK
asterisk.timegroups_groups OK
asterisk.trunk_dialpatterns OK
asterisk.trunks OK
asterisk.users OK
asterisk.vmblast OK
asterisk.vmblast_groups OK
asterisk.zap OK
asterisk.zapchandids OK

vegastech
vegastech's picture
If I use the User Control

If I use the User Control Panel I can see the messages there and listen to them via the phone or download. So the messages are not mangled. That interface accepts the extension and password with no problem. That makes me think the voicemail system is fine, mind you there are only (2) voicemail extensions in this office. I also tried to access the voicemail using *98 from another phone, same thing - silence then hangs up after 10 secs.

Getting kinda stuck here.

glew
glew's picture
i have the same problem i try

i have the same problem i try whit

mysqlcheck -ufreepbxuser -p --auto-repair asterisk cdr and
mysqlcheck -uroot -p --auto-repair asterisk cdr

When ask for the password i try all passwords and every time givme
mysqlcheck: Got error: 1045: Access denied for user 'freepbxuser'@'localhost' (using password: YES) when trying to connect
i dont know how to repair

dicko
dicko's picture
you can't repair it until you

you can't repair it until you know your password,.

If you are unfamiliar with how the internet works try:-

http://letmegooglethtforyou.com/?q=reset+mysql+root+password

dicko
dicko's picture
oh hum . . .
wjohnny21
wjohnny21's picture
i have the same problem

me to

i have the same problem when i try with

mysqlcheck -ufreepbxuser -p --auto-repair asterisk cdr and
mysqlcheck -uroot -p --auto-repair asterisk cdr

then i got this reply >> mysqlcheck: Got error: 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) when trying to connect
i don't know hao to fix it...
somebody please help me ..??

dicko
dicko's picture
MThe mysql server needs to be

MThe mysql server needs to be running before you can do anything else. When you get it going, there are only two tables to worry about, asterisk and asteriskcdrdb

mysqlcheck -pyourpassword -uroot asterisk cdr

won't work.

jmmicmc
jmmicmc's picture
I have a similar problem

When I try the command "mysqlcheck -ufreepbxuser -ppassword --auto-repair asteriskcdrdb crd" it asks for a password. The only password I used when installing the software doesn't work. If I reset the password, will asterisk be able to use it?

James

dicko
dicko's picture
it would work if your

it would work if your username was freepbxuser and your password where password, If you use the "FreePBX distro" for some strange reason there is no password set for the root user from localhost for mysql so you can leave out all that inconvenient authority checking Smile

jmmicmc
jmmicmc's picture
I reset the root password to

I reset the root password to something, and was able to use the commands given to fix the asterisk and asteriskcdrdb databases. However now I am back to where I started - the same error in the first post here:
FATAL ERROR
DB Error: connect failed
Trace Back
/var/www/html/admin/libraries/db_connect.php:63 die_freepbx()
[0]: DB Error: connect failed

/var/www/html/admin/bootstrap.php:98 require_once()
[0]: /var/www/html/admin/libraries/db_connect.php

/etc/freepbx.conf:9 require_once()
[0]: /var/www/html/admin/bootstrap.php

/var/www/html/admin/config.php:109 include_once()
[0]: /etc/freepbx.conf

The password for asterisk and asteriskcdrdb is "password" and the root password is "amp111". The databases were fixed, but they are not available to asterisk. Any ideas?

James

jmmicmc
jmmicmc's picture
databases

Will I have to reinstall? Does someone know what the passwords should be?

James

jmmicmc
jmmicmc's picture
I have put the mysql root

I have put the mysql root password to "". This also does not help. Does someone know what to do?

James

SkykingOH
SkykingOH's picture
FreePBX uses the mysql users

FreePBX uses the mysql users defined in /etc/freepbx.conf

They have to match the sql credentials.

jmmicmc
jmmicmc's picture
Reinstalling

I did find the credentials, an was able to get into the administratin interface, but it did not work right: was not able to get into some menu items, and everytime I clicked into any menu selection I would have to re-enter my credentials.
This brings an important matter, does the UPS monitoring work on the freepbx? With APC?
James

SkykingOH
SkykingOH's picture
CentOS can monitor most UPS

CentOS can monitor most UPS

maxysadm
maxysadm's picture
Same here

Hi! I´m a noob in this so don´t judge for the basic questions..

I have the same error every time I reboot the server:
FATAL ERROR
DB Error: connect failed
Trace Back
/var/www/html/admin/libraries/db_connect.php:63 die_freepbx()
[0]: DB Error: connect failed

/var/www/html/admin/bootstrap.php:98 require_once()
[0]: /var/www/html/admin/libraries/db_connect.php

/etc/freepbx.conf:9 require_once()
[0]: /var/www/html/admin/bootstrap.php

/var/www/html/admin/config.php:109 include_once()
[0]: /etc/freepbx.conf

usually solved with
"
service mysqld stop
mv /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock.bak
service mysqld start
"
How can I stop the error? this started a week ago and I´m not being abble to find any solution to it..

any help will be much apreciated,

Regards.

reconwireless
reconwireless's picture
If using the FreePBX Distro,

If using the FreePBX Distro, update to the latest version, we have put in fixes for the mysql issues. Also you may want to make sure you are properly shutting down your system.

Preston McNair | FreePBX/Schmooze Com, Inc

 

maxysadm
maxysadm's picture
Currently running 5.211.65-6.

Currently running 5.211.65-6.

Is "Shutdown now" the wrong way to do a clean shutdown? What could be the work around to fix this mysql issue?

Thank you for your help

tm1000
tm1000's picture
We have put the work around

We have put the work around into the distro. There's nothing more you need to do.

Senior Developer
Schmoozecom, INC

reconwireless
reconwireless's picture
If you didn't install using

If you didn't install using our Distro, try shutting down using this command.

init 6

That should shutdown all of your daemons, then lastly invoke shutdown -r to reboot the machine.

Preston McNair | FreePBX/Schmooze Com, Inc