After Upgrade i get Exception: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket

Hi, I upgraded my freepbx the i get this error
Exception: SQLSTATE[HY000] [2002] Can’t connect to local MySQL server through socket ‘%2Fvar%2Flib%2Fmysql%2Fmysql.sock’ (2)::SQLSTATE[HY000] [2002] Can’t connect to local MySQL server through socket ‘%2Fvar%2Flib%2Fmysql%2Fmysql.sock’ (2) in file /var/www/html/admin/libraries/utility.functions.php on line 204
Stack trace:

  1. Exception->() /var/www/html/admin/libraries/utility.functions.php:204
  2. die_freepbx() /var/www/html/admin/libraries/BMO/Database.class.php:138
  3. PDOException->() /var/www/html/admin/libraries/BMO/Database.class.php:135
  4. PDO->__construct() /var/www/html/admin/libraries/BMO/Database.class.php:135
  5. FreePBX\Database->__construct() /var/www/html/admin/libraries/BMO/FreePBX.class.php:68
  6. FreePBX->__construct() /var/www/html/admin/bootstrap.php:141
  7. require_once() /etc/freepbx.conf:11
  8. include_once() /var/lib/asterisk/bin/fwconsole:12
    i checked mysql its working, also i tried to connect to it and it works i don’t get it. Thanks for any input you can provide.

Your HD is likely full.

I have 76 GB available and 2.39 of 32 GB memory.

Repair your database tables and restart the MySQL/MariaDB server.

i did repair the database still the same error. I have question does db user which is the defaul user of freepbx need to have all privileges?

OK, time to start the obvious questions:

  1. Are you running the database on the local server or are you using a remote database?
  2. When you log into the server (through the console) to do the repair, what command did you use?
  3. The ‘root’ user doesn’t normally have a password, but is limited to the local machine. The Asterisk DB user (which varies from version to version) does use a password. Log in as ‘root’ on the console and type the following:

mysql -u root

(once in MySQL)

select username from mysql.users;

This command might be ‘user’ instead of ‘username’ - I don’t have access to a FreePBX database right now.

This will tell you what users are available.

To answer your specific question - the root user should have all rights to all databases and tables. The asterisk database user should have most of the permissions (they don’t need the Administrator permissions, but they should have all of the data permissions) to the asterisk tables. Note that there may be other databases that this user should have (if you’ve added additional databases to the system, for example).

1- I’m running on both local and remote database
For the cdr database its on a remote but the reste on the local server
2- I used mysqlcheck --repair --all-databases and
myisamchk --recover --extend-check --force /var/lib/mysql//.MYI
3- I did what you suggested I got 4 users 1 of them is freepbxuser.
Thank you.

There are a couple of ways to restart the database. The first is to issue a “service start mysqld” or the equivalent (could be “mysql” or “mariadb” instead of “mysqld”). Make sure the service starts with a ‘ps aux | grep mysql’ command at the console. This will tell you if the database server is started. If it is, the problem is probably in your Asterisk config. If it isn’t, look for the error file in the database data file directory (/var/db or /var/mysql/ for example). The should be a “hostname.err” where hostname is something like the name of your computer. The /etc/my.cnf file should have the default data store directory name.

Hi, I did that and my cnf looks good, also the log file is empty

Did you get this resolved? I am seeing a similar issue.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.