Can't connect to local MySQL server

I using FreePBX 13.0.197.22
I’m only using 27% disk space
Before I reboot the server I run fwconsole stop.
The server reboot with the following error

Exception: SQLSTATE[HY000] [2002] Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (111)::SQLSTATE[HY000] [2002] Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (111) 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:134
  3. PDOException->() /var/www/html/admin/libraries/BMO/Database.class.php:131
  4. PDO->__construct() /var/www/html/admin/libraries/BMO/Database.class.php:131
  5. FreePBX\Database->__construct() /var/www/html/admin/libraries/BMO/FreePBX.class.php:72
  6. FreePBX->__construct() /var/www/html/admin/bootstrap.php:145
  7. require_once() /etc/freepbx.conf:9
  8. include_once() /var/lib/asterisk/bin/fwconsole:12

I tried service mysqld start
MySQL Daemon failed to start.
Starting mysqld: [FAILED]

Content of my Mysql.log
190207 23:35:01 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
190207 23:35:22 InnoDB: Initializing buffer pool, size = 8.0M
190207 23:35:22 InnoDB: Completed initialization of buffer pool
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
190207 23:35:23 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files…
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer…
190207 23:35:30 InnoDB: Started; log sequence number 0 8772053
190207 23:35:34 [Note] Event Scheduler: Loaded 0 events
190207 23:35:34 [Note] /usr/libexec/mysqld: ready for connections.
Version: ‘5.1.73’ socket: ‘/var/lib/mysql/mysql.sock’ port: 3306 Source distribution
190504 7:27:25 [ERROR] /usr/libexec/mysqld: Got error 134 from storage engine
190504 7:27:25 [ERROR] /usr/libexec/mysqld: Sort aborted
200504 20:38:50 [Note] /usr/libexec/mysqld: Normal shutdown

200504 20:38:50 [Note] Event Scheduler: Purging the queue. 0 events
200504 20:38:50 InnoDB: Starting shutdown…
200504 20:39:21 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
200504 20:39:21 InnoDB: Initializing buffer pool, size = 8.0M
200504 20:39:21 InnoDB: Completed initialization of buffer pool
200504 20:39:22 InnoDB: Started; log sequence number 0 9459016
200504 20:39:22 [ERROR] /usr/libexec/mysqld: Can’t create/write to file ‘/var/run/mysqld/mysqld.pid’ (Errcode: 2)
200504 20:39:22 [ERROR] Can’t start server: can’t create PID file: No such file or directory
200504 20:39:22 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
200504 20:43:21 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
200504 20:43:22 InnoDB: Initializing buffer pool, size = 8.0M
200504 20:43:22 InnoDB: Completed initialization of buffer pool
200504 20:43:22 InnoDB: Started; log sequence number 0 9459016
200504 20:43:22 [ERROR] /usr/libexec/mysqld: Can’t create/write to file ‘/var/run/mysqld/mysqld.pid’ (Errcode: 2)
200504 20:43:22 [ERROR] Can’t start server: can’t create PID file: No such file or directory
200504 20:43:22 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
200504 21:26:05 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
200504 21:26:06 InnoDB: Initializing buffer pool, size = 8.0M
200504 21:26:06 InnoDB: Completed initialization of buffer pool
200504 21:26:06 InnoDB: Started; log sequence number 0 9459016
200504 21:26:06 [ERROR] /usr/libexec/mysqld: Can’t create/write to file ‘/var/run/mysqld/mysqld.pid’ (Errcode: 2)
200504 21:26:06 [ERROR] Can’t start server: can’t create PID file: No such file or directory
200504 21:26:06 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
200504 21:37:21 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
200504 21:37:21 InnoDB: Initializing buffer pool, size = 8.0M
200504 21:37:21 InnoDB: Completed initialization of buffer pool
200504 21:37:22 InnoDB: Started; log sequence number 0 9459016
200504 21:37:22 [ERROR] /usr/libexec/mysqld: Can’t create/write to file ‘/var/run/mysqld/mysqld.pid’ (Errcode: 2)
200504 21:37:22 [ERROR] Can’t start server: can’t create PID file: No such file or directory
200504 21:37:22 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

I appreciate any help.

Hi,

It looks like a permission issue so could you try with below commands and see that resolves the issues or not.

"
chown mysql:mysql /var/run/mysqld
service mysqld start

"

chown mysql:mysql /var/run/mysqld

chown: cannot access `/var/run/mysqld’: No such file or directory

Content of /var/run
[[email protected] run]# ls -l
total 52
-rw-r–r-- 1 root root 5 May 4 21:26 acpid.pid
srw-rw-rw- 1 root root 0 May 4 21:26 acpid.socket
drwxrwxr-x 3 asterisk asterisk 4096 May 4 20:39 asterisk
-rw-r–r-- 1 root root 4 May 4 21:26 auditd.pid
drwxr-xr-x 2 avahi avahi 4096 May 4 21:26 avahi-daemon
-rw-r–r-- 1 root root 5 May 4 21:26 crond.pid
---------- 1 root root 0 May 4 21:26 cron.reboot
-rw-r–r-- 1 root root 5 May 4 21:26 dnsmasq.pid
srwxr-xr-x 1 root root 0 May 4 21:26 fop2.ctl
-rw-r–r-- 1 root root 4 May 4 21:26 fop2.pid
-rw-r–r-- 1 root root 4 May 4 21:26 incrond.pid
-rw-r–r-- 1 root root 4 May 4 21:26 ntpd.pid
-rw-r–r-- 1 root root 5 May 4 21:26 sshd.pid
-rw------- 1 root root 4 May 4 21:26 syslogd.pid
-rw-rw-r-- 1 root utmp 3840 May 5 00:03 utmp
-rw-r–r-- 1 root root 5 May 4 21:26 xinetd.pid

HI,
Mysqld directory itself missing so can you try to create the mysqld directory under “/var/run” and then try to start the MySQL service.

"
mkdir mysqld
chown mysql:mysql mysqld
chmod 755 mysqld
"

I created mysqld, change 755 and start the service
IT seems to load mysql but there was an error with Fail2ban
I created /var/run/fail2ban and run fwconsole stop, then fwconsole start (no error)

I can use ext 102 to call ext 101and dial outside line, It works

But No GUI
This site can’t be reached
x.x.x.x refused to connect

Compare to other PBX, I’m missing a lot of folder under /var/run
These are the only folder and files under /van/run
-rw-r–r-- 1 root root 5 May 5 01:00 acpid.pid
srw-rw-rw- 1 root root 0 May 5 01:00 acpid.socket
drwxrwxr-x 3 asterisk asterisk 4096 May 5 01:03 asterisk
-rw-r–r-- 1 root root 4 May 5 01:00 auditd.pid
drwxr-xr-x 2 avahi avahi 4096 May 5 01:00 avahi-daemon
-rw-r–r-- 1 root root 5 May 5 01:00 crond.pid
---------- 1 root root 0 May 5 01:00 cron.reboot
-rw-r–r-- 1 root root 5 May 5 01:00 dnsmasq.pid
drwxr-xr-x 2 root root 4096 May 5 01:01 fail2ban
srwxr-xr-x 1 root root 0 May 5 01:01 fop2.ctl
-rw-r–r-- 1 root root 4 May 5 01:01 fop2.pid
-rw-r–r-- 1 root root 4 May 5 01:01 incrond.pid
drwxr-xr-x 2 mysql mysql 4096 May 5 01:00 mysqld
-rw-r–r-- 1 root root 4 May 5 01:00 ntpd.pid
-rw-r–r-- 1 root root 5 May 5 01:00 sshd.pid
-rw------- 1 root root 4 May 5 01:00 syslogd.pid
-rw-rw-r-- 1 root utmp 3456 May 5 01:02 utmp
-rw-r–r-- 1 root root 5 May 5 01:00 xinetd.pid

Thank’s for your help

I created httpd and and run fwconsole restart
The GUI start working.

Should I be concern about the other folder missing under /var/run. Everything seems to be working

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