FATAL ERROR DB Error: insufficient permissions

Okay, seems I got my FreePBX messed up.

I’m able to ssh into my box, but when I go to the FreePBX default web site I get the Fatal Error below. My distribution is CentOS, with Asterisk & FreePBX loaded on top of it. Everything was working, then I got the great idea of rebooting and wound up with this issue. I am not sure what I did to break it.

FATAL ERROR

DB Error: insufficient permissions

Trace Back

/var/www/html/admin/libraries/db_connect.php:72 die_freepbx()
[0]: DB Error: insufficient permissions

/var/www/html/admin/bootstrap.php:85 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:99 include_once()
[0]: /etc/freepbx.conf

We need more information about your system. Versions OS etc.

What did you do just prior to it stopping working?

Hi SkykingOH, thanks for the note. I’m not sure how to get the versions…

Here’s what I have from Webmin:

   Operating system CentOS Linux 6.5
   Webmin version 1.680
   Kernel and CPU Linux 2.6.32-431.17.1.el6.x86_64 on x86_64

Oh, and I just got Asterisk version with “asterisk -r” (not the right way I know):

   Asterisk 11.9.0

I don’t know how to get into FreePBX… ?

Just prior to it stopping working, I was just adding extensions and routes as far as I remember. It had been a few days since I rebooted, so I decided to reboot to make sure everything would be okay. And… it wasn’t okay.

I suspect I had done something earlier in the week that caused it. I do remember sometime in the previous week or two that I changed the mysql passwords, but I think all of those are okay because the system is operational – just not the gui.

I can make and receive calls (so that part of the database is okay I think), I can log into the shell, Webmin works fine (which uses mysql too I think).

remove your mysql lock file and reboot.

Hi jfinstrom, I don’t know how to “remove your mysql lock file”. That said, I’m pretty sure mysql is running. I did just do an updatedb and reboot, but nothing changed.

updatedb doesn’t do what you think it does.
Linux 101:

info

will often explain a command to you also

man

You can remove the lock with:

rm /var/lock/subsys/mysqld

I’ve progressed! Maybe. Or not.

I started thinking, maybe if I have an alternate way of accessing the GUI, instead of through the www, I’d be able to get to FreePBX. So… I found a reference to the following:

chkconfig --list httpd
httpd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
chkconfig --list mysqld
mysqld 0:off 1:off 2:off 3:on 4:on 5:on 6:off

I performed:
chkconfig httpd on
chkconfig mysqld on
/etc/rc.d/init.d/httpd restart

And now
mysqld 0:off 1:off 2:off 3:on 4:on 5:on 6:off
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Now the GUI error I receive is…

FATAL ERROR

DB Error: connect failed

Trace Back

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

/var/www/html/admin/bootstrap.php:85 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:99 include_once()
[0]: /etc/freepbx.conf

Hi jfinstrom,

Thanks for the note.

rm /var/lock/subsys/mysqld << no change. Still same issue.

did you reboot after?

Yes, rebooted afterwards. Still no love. I did do some other things listed in the next post, and now I’m receiving a different error.

mysqlcheck --repair --all-databases

Everything shows up as “OK”.

[[email protected] ~]# mysqlcheck -uroot -pmysql --repair --all-databases
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.callrecording OK
asterisk.callrecording_module OK
asterisk.cidlookup OK
asterisk.cidlookup_incoming OK
asterisk.cronmanager OK
asterisk.custom_destinations OK
asterisk.custom_extensions OK
asterisk.dahdi OK
asterisk.dahdichandids OK
asterisk.daynight OK
asterisk.devices OK
asterisk.digium_phones_alerts OK
asterisk.digium_phones_customapp_settings OK
asterisk.digium_phones_customapps OK
asterisk.digium_phones_device_alerts OK
asterisk.digium_phones_device_customapps OK
asterisk.digium_phones_device_externallines OK
asterisk.digium_phones_device_logos OK
asterisk.digium_phones_device_networks OK
asterisk.digium_phones_device_phonebooks OK
asterisk.digium_phones_device_settings OK
asterisk.digium_phones_device_statuses OK
asterisk.digium_phones_devices OK
asterisk.digium_phones_extension_settings OK
asterisk.digium_phones_externalline_settings OK
asterisk.digium_phones_externallines OK
asterisk.digium_phones_firmware OK
asterisk.digium_phones_firmware_packages OK
asterisk.digium_phones_general OK
asterisk.digium_phones_lines OK
asterisk.digium_phones_logos OK
asterisk.digium_phones_network_settings OK
asterisk.digium_phones_networks OK
asterisk.digium_phones_phonebook_entries OK
asterisk.digium_phones_phonebook_entry_settings OK
asterisk.digium_phones_phonebooks OK
asterisk.digium_phones_queues OK
asterisk.digium_phones_ringtones OK
asterisk.digium_phones_status_entries OK
asterisk.digium_phones_status_settings OK
asterisk.digium_phones_statuses OK
asterisk.digium_phones_voicemail_translations OK
asterisk.digiumaddoninstaller_addons OK
asterisk.digiumaddoninstaller_addons_downloads OK
asterisk.digiumaddoninstaller_downloads OK
asterisk.digiumaddoninstaller_downloads_ast_versions OK
asterisk.digiumaddoninstaller_downloads_bits OK
asterisk.digiumaddoninstaller_registers OK
asterisk.digiumaddoninstaller_system 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.freepbx_users OK
asterisk.freepbx_users_settings OK
asterisk.globals OK
asterisk.googlevoice OK
asterisk.hotelwakeup OK
asterisk.hotelwakeup_calls OK
asterisk.iax OK
asterisk.iaxsettings OK
asterisk.incoming OK
asterisk.indications_zonelist OK
asterisk.ivr_details OK
asterisk.ivr_entries OK
asterisk.logfile_logfiles OK
asterisk.logfile_settings OK
asterisk.meetme OK
asterisk.miscapps OK
asterisk.miscdests OK
asterisk.module_xml OK
asterisk.modules OK
asterisk.motif 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.parkplus OK
asterisk.pinset_usage OK
asterisk.pinsets OK
asterisk.presencestate_list OK
asterisk.presencestate_prefs 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.superfecta_mf OK
asterisk.superfecta_mf_child OK
asterisk.superfecta_to_incoming OK
asterisk.superfectacache OK
asterisk.superfectaconfig 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.voicemail_admin OK
asteriskcdrdb.cdr OK
asteriskcdrdb.cel OK
mysql.columns_priv OK
mysql.db OK
mysql.event OK
mysql.func OK
mysql.general_log OK
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.host OK
mysql.ndb_binlog_index OK
mysql.plugin OK
mysql.proc OK
mysql.procs_priv OK
mysql.servers OK
mysql.slow_log OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK

Okay, when the server is first rebooted, this error occurs:

      FATAL ERROR
      DB Error: insufficient permissions

If these commands are entered:
chkconfig httpd on
chkconfig mysqld on
/etc/rc.d/init.d/httpd restart

This error results:

      FATAL ERROR
      DB Error: connect failed

I just think that he has his DB password hosed.

Make sure that /etc/freepbx.conf matches the account name and password in mysql.

Then service mysqld restart and amportal restart

Okay, I considered the password issue you suggested. I tried

[[email protected] ~]# mysqlcheck -uasterisk -pmysql --repair --all-databases
mysqlcheck: Got error: 1045: Access denied for user ‘asterisk’@‘localhost’ (using password: YES) when trying to connect

So then I went into Webmin and created a user [email protected] (the other asterisk user is host “Any”).

“amportal restart” doesn’t work.

[[email protected] ~]# amportal restart

Please wait…
/usr/local/sbin/amportal: line 46: [FATAL]: command not found

/var/lib/asterisk/bin/freepbx_engine: line 98: [FATAL]: command not found
**** WARNING: ERROR IN CONFIGURATION ****
astrundir in ‘/etc/asterisk’ is set to but the directory
does not exists. Attempting to create it with: 'mkdir -p ’

mkdir: missing operand
Try `mkdir --help’ for more information.
**** ERROR: COULD NOT CREATE ****
Attempt to execute 'mkdir -p ’ failed with an exit code of 1
You must create this directory and the try again.

stop digging. read the post from SkyKingOH

Yes, what in the world did you change? astrundir is is not /etc/asterisk

Can you just post the file please and we will tell you what to do?

Which file? Here is freepbx.conf

[[email protected] etc]# more /etc/freepbx.conf

<?php $amp_conf['AMPDBUSER'] = ''; $amp_conf['AMPDBPASS'] = ''; $amp_conf['AMPDBHOST'] = 'localhost'; $amp_conf['AMPDBNAME'] = 'asterisk'; $amp_conf['AMPDBENGINE'] = 'mysql'; $amp_conf['datasource'] = ''; //for sqlite3 require_once('/var/www/html/admin/bootstrap.php');

Did you notice they are blank?

Add a user with full permissions to asterisk and asteriskcdrdb, these are examples and assume root has no password if it does add the -uxxxx where xxxx is username and -p

In this example I am creating an ampdbuser called foo and ampdbpass called bar

mysql -u root -p -e "GRANT ALL PRIVILEGES ON asterisk.* TO [email protected] IDENTIFIED BY 'bar';"
mysql -u root -p -e "GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO [email protected] IDENTIFIED BY 'bar';"
mysql -u root -p -e "flush privileges;"

Then in you file:

<?php
$amp_conf['AMPDBUSER'] = 'foo';
$amp_conf['AMPDBPASS'] = 'bar';
$amp_conf['AMPDBHOST'] = 'localhost';
$amp_conf['AMPDBNAME'] = 'asterisk';
$amp_conf['AMPDBENGINE'] = 'mysql';
$amp_conf['datasource'] = ''; //for sqlite3

require_once('/var/www/html/admin/bootstrap.php');

Skyking, thanks. I actually didn’t follow that the blanks were not acceptable. I did as you suggested (added foo), and I can get to the GUI now.

Unfortunately, now I have
"Server Status Asterisk ERROR" with
"[FATAL] retreive_conf failed to get engine information and cannot configure up a softwitch with out it. Error: ERROR-UNABLE-TO-PARSE"

^^ of course, should be retrieve_conf, so I’m not sure if yet something else to messed up, or if that is just an error in the error parser.

I think I’m going to reinstall from scratch. I am not sure what I’ve done to the system, but that AMPDBUSER was blank doesn’t make much sense to me. I haven’t edited any of the files manually up until now.