1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. If you had a PIAF Forum account in the vBulletin days, log in with your old credentials. Otherwise, sign up again and we'll get you back in business as soon as we can.
  3. A serious FreePBX vulnerability has been reported. Update your Framework Module immediately. Click here for details.

SOLVED FIX: MySQL DB Error

Discussion in 'Bug Reporting and Fixes' started by wa4zlw, Apr 7, 2014.

  1. wa4zlw Member

    WE had some sort of power outage last night and looks like the UPSes didn't keep everything up. THat might explain why a call via vitelity got rejected. When I tried to login tonight I got this:

    FATAL ERROR

    DB Error: connect failed

    Trace Back

    /var/www/html/admin/common/db_connect.php:63 die_freepbx()
    [0]: DB Error: connect failed

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

    /var/www/html/admin/config.php:61 require()
    [0]: /var/www/html/admin/bootstrap.php

    here's what I have:

    PBX in a Flash PURPLE Status Program
    qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
    lqqqqqqqqqqqqqqqqqqqSYSTEM INFORMATION *VERIFIED*qqqqqqqqqqqqqqqqqqqqqk
    x Asterisk = OFFLINE | Dahdi = ONLINE | MySQL = OFFLINE x
    x SSH = ONLINE | Apache = ONLINE | Iptables = ONLINE x
    x Fail2ban = ONLINE | Internet = ONLINE | Ip6Tables = ONLINE x
    x Disk Free = ADEQUATE| Mem Free = ADEQUATE| NTPD = ONLINE x
    x Postfix = ONLINE | Samba = ONLINE | Webmin = ONLINE x
    x Ethernet0 = ONLINE | Ethernet1 = N/A | Wlan0 = N/A x
    x x
    x PIAF Installed Version = 2.0.6.4 under *HARDWARE* x
    x FreePBX Version = 2.9.0.14 x
    x Running Asterisk Version = UNKNOWN x
    x Asterisk Source Version = 1.8.20.1 x
    x Dahdi Source Version = 2.6.2 x
    x Libpri Source Version = 1.4.12 x
    x IP Address = 10.161.51.10 on eth0 x
    x Operating System = CentOS release 6.4 (Final) x
    x Kernel Version = 2.6.32-358.2.1.el6.i686 - 32 Bit x
    x Incredible PBX 3 Version = 3.1.0 x
    mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj



    root@pbx:~ $
    thoughts? thanks leon
  2. atsak Guru

    Your DB is corrupt :banghead: it would seem, at a minimum, and maybe some of the rest of the hard drive.

    Run fsck first, then do some googling for repairing a MySQL database. You can try service mysqld start as well then log in /var/log/messages to see if you can figure out why it isn't starting or which table is corrupt.

    PS I am not a Linux experts these instructions should be expounded on and perhaps corrected by others.
  3. wa4zlw Member

    i'm definitely not a linux guru...but it makes sense.

    I'm going to try a reboot of the box since stopping and restarting the daemon fails

    root@pbx:~ $ service mysqld start
    Another MySQL daemon already running with the same unix socket.
    Starting mysqld: [FAILED]
    root@pbx:~ $ service mysqld stop
    Stopping mysqld: [ OK ]
    root@pbx:~ $ service mysqld start
    Another MySQL daemon already running with the same unix socket.
    Starting mysqld: [FAILED]
    root@pbx:~ $

    ok that (reboot) failed....:-(
  4. tm1000 Schmoozecom INC/FreePBX

    No. Don't just jump to conclusions. You know nothing about his hard drive or system. This is an error with an upstream update from Oracle where-as if there is a power outage mysql doesn't remove the socket file on a reboot from a power outage (or you pulling the plug) and instead thinks it's already running when it's not. This is fixed in the FreePBX distro, but for other distros they will need to just:

    Code:
    service mysqld stop
    rm -Rf /var/lib/mysql/mysql.sock
    service mysqld start
    
    krzykat and wardmundy like this.
  5. wa4zlw Member

    Ok thanks I'll try it in the morning

    Leon
  6. wa4zlw Member

    That works thanks. Is this in new distro?

    Leon
  7. tm1000 Schmoozecom INC/FreePBX

    As I said. It is not in PIAF. Only the FreePBX Distro
  8. wa4zlw Member

    looks like we had a power failure and my UPS batteries need replacing

    got this again

    FATAL ERROR

    DB Error: connect failed

    Trace Back

    /var/www/html/admin/common/db_connect.php:63 die_freepbx()
    [0]: DB Error: connect failed

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

    /var/www/html/admin/config.php:61 require()
    [0]: /var/www/html/admin/bootstrap.php


    guess I have to do what I did last time?

    leon

  9. wa4zlw Member

    this time the script worked but I had to amportal restart twice

    leon
  10. wa4zlw Member

    hi guys this happened again with another box

    qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
    lqqqqqqqqqqqqqqqqqqqqqqqqSYSTEM INFORMATIONqqqqqqqqqqqqqqqqqqqqqqqqqqqk
    x Asterisk = ONLINE | Dahdi = ONLINE | MySQL = ONLINE x
    x SSH = ONLINE | Apache = ONLINE | Iptables = ONLINE x
    x Fail2ban = ONLINE | Internet = ONLINE | Ip6Tables = ONLINE x
    x Disk Free = ADEQUATE| Mem Free = ADEQUATE| NTPD = ONLINE x
    x Postfix = ONLINE | Samba = ONLINE | Webmin = ONLINE x
    x Ethernet0 = ONLINE | Ethernet1 = N/A | Wlan0 = N/A x
    x x
    x PIAF Installed Version = 2.0.6.4 under *HARDWARE* x
    x FreePBX Version = 2.11.0.36 x
    x Running Asterisk Version = 11.6.0 x
    x Asterisk Source Version = 11.6.0 x
    x Dahdi Source Version = 2.7.0.1 x
    x Libpri Source Version = 1.4.14 x
    x IP Address = 10.196.4.10 on eth0 x
    x Operating System = CentOS release 6.4 (Final) x
    x Kernel Version = 2.6.32-358.23.2.el6.i686 - 32 Bit x
    x Incredible Version = 11.7 x
    mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj


    the script fixed it -- can this be put in as a script that runs on boot?

    thanks leon
  11. james Guru

  12. wa4zlw Member

    thanks...I'd really like to see things like this part of the distro instead of having to add stuff piecemeal. TO me it makes perfect sense.

    leon
  13. wardmundy Nerd Uno

    This is a most unusual occurrence unless you have hardware issues. In 8 years I've never once seen it happen.
  14. wa4zlw Member

    Hey ward. This is on two different boxes. One an older dell with real HD (home). The other newer box with ssd (synagogue ). In both cases I believe the boxes were rebooted with power down. One at home due to ups battery fail. Synagogue they just did it.

    I'm trying to get them not to do that to at least do a C-A-D but still having a script to clear this anomoly (sp?) seems to make sense to me. Through I out my embedded software career if always look at failure modes and how to program for them and understand them

    Leon
  15. wardmundy Nerd Uno

    If damage to this file is all you experience after a power cut on a Linux box, you were damn lucky.

    Having said that, if you want this run each time your server boots, just issue these commands to add it to the rc.local file ABOVE the exit 0 final line:

    Code:
    echo "service mysqld stop" >> /etc/rc.d/rc.local
    echo "rm -Rf /var/lib/mysql/mysql.sock" >> /etc/rc.d/rc.local
    echo "service mysqld start" >> /etc/rc.d/rc.local
    
    Last edited by wardmundy, Sep 5, 2014
  16. atsak Guru

    In this day and age, I must respectfully disagree. All modern operating systems almost always recover from unexpected power outages IME. There may well be a little data loss, but I would consider it unlucky to have anything more than a minor inconvenience. No excuse not to have a UPS of course, but unlikely with recent file systems (especially journaling ones) to have a major catastrophe.
  17. wa4zlw Member

    UPSes at both sites. At my site I need to replace battery. But I agree and said before this should be in the distro. Thanks again. Leon
  18. atsak Guru


    Ya, I've gotten a lot more vigilant about recording when I install a UPS and putting a calendar entry (literally) to replace the battery proactively after 3 years unless it's failed before that. So far so good.
    wardmundy likes this.
  19. wa4zlw Member

    hi folks after another power blip this morning and not having time to get things swapped out; I tried Wards script and it fails:


    root@pbx:~ $ echo "service mysqld stop" >> /etc/rc.d./rc.local
    -bash: /etc/rc.d./rc.local: No such file or directory
    root@pbx:~ $ echo "rm -Rf /var/lib/mysql/mysql.sock" >> /etc/rc.d./rc.local
    -bash: /etc/rc.d./rc.local: No such file or directory
    root@pbx:~ $ echo "service mysqld start" >> /etc/rc.d./rc.local
    -bash: /etc/rc.d./rc.local: No such file or directory

    not being a linux guru, I'm stumped.

    thanks leon
  20. wardmundy Nerd Uno

    Remove (typo) period after rc.d. in each line. Sorry.

Share This Page