Need urgent help, asterisk mysql database is messed up!

Hey everyone,

So I screwed up my system good on the weekend. I was trying to install Queue Analyzer a plugin I found online. The installer for it kept failing when running the installation script. When I’d try to make database asterisk like it said, it would say that the database exists. Their stupid manual said if that happens, then to “drop database asterisk” and run their script which I did. This made their program work, however now I can’t access my admin portal at all. Going to http://serverip/admin I get:

FATAL ERROR

DB Error: connect failed

Trace Back

Array
(
[0] => Array
(
[file] => /var/www/html/admin/common/db_connect.php
[line] => 69
[function] => die_freepbx
[args] => Array
(
[0] => DB Error: connect failed
)

Followed by a bunch more messages like that. I don’t know why I ran that command but it sounds like drop deleted the asterisk table :S What do I do!!!

This occurred while I was installing iaxmodem.

I suspect ldconfig with the changes suggested by the iax installation manual is what broke it, unfortunately undoing that change still has not got PHP working with the mysql libraries…

[[email protected] ~]# php
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/modules/mysql.so’ - libmysqlclient.so.15: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/modules/mysqli.so’ - libmysqlclient.so.15: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/modules/pdo_mysql.so’ - libmysqlclient.so.15: cannot open shared object file: No such file or directory in Unknown on line 0

any idea how to fix this without a complete rebuild? Installing Elastix seems like a better idea at this point due to the desire to have faxing (its build in the wrapper) not to mention the box is on RAID5 (eek!)

Thanks for any input,

-Jake

Ah that worked! You’re the best thanks so much! Only thing that doesn’t work is FOP2 but that may just need to be reinstalled, but minor concern. The portal and FreePBX all work again thank you so much!

Hey thanks for the help, I’m having issues for some reason. I did everything you said and it seemed to have restored the sql file, however I still have all the same issues. I ran amportal restart, restarted the mysql service etc but still gives me the exact same problems… Is there anything further I’d need to do to make it work? I haven’t restarted the whole server yet as people are using the phones so can’t try that until later…

This is worth trying, though I’m not sure it will fix your problem. Your other install script could have done other things that screwed with your FreePBX install. From the FreePBX install documentation, there are commands you issue to grant privileges to the database:

GRANT ALL PRIVILEGES ON asterisk.* TO [email protected] IDENTIFIED BY ‘SOMEPASSWORD’;

do that from the “mysql” command as root, and replace “asteriskuser” and ‘SOMEPASSWORD’ with the database user and password you have defined in amportal.conf. See if that gets it connected.

I have it backed up but how do I restore it if I can’t access the admin portal to click on restore database? What a piece of crap add on, it wasn’t even a command I typed, the installer script for the queue analyzer had as the very first command in the install.sh file “drop database asterisk”.

Also what’s even in the mysql database asterisk anyway? My phones all work perfectly fine I have no issues I just can’t access the GUI. If it wasn’t for that nothing has changed. Is the database specific to my setup or is it generic? I have it backed up but everything works aside from gui.

Do it from the command line.

Go to the directory where your backups are stored (mine are in a directory under /var/lib/asterisk/backups) and then issue “tar zxvf 2011…” (the rest of the backup file name).

Then cd to tmp/ampbackups.2011… (rest of name)

You will find a file called asterisk.sql; that’s your asterisk database.

As root, run “mysql < asterisk.sql” and that should rebuild your asterisk database.

Asterisk will work perfectly fine because it runs from the conf files. FreePBX uses this database to build the conf files.

First off, please don’t put ‘urgent’ in the subject line, it’s annoying.

Is something is urgent or you are down the team at FreePBX support is available to help and you are supporting the project.

When you type commands you don’t know what they do you are always at risk for situations such as this.

Do you have a backup of your database? If not you are SOL.

… and just to be pedantic about it,

“drop database asterix”

did exactly that. It deleted the asterix database in it’s entirety.

http://www.w3schools.com/sql/sql_drop.asp