title: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111 "Connection refused") centos 6
body: <p>Centos 6, openlitespeed installed, using MariaDB</p>
  
  <p>MySQL works normally until it suddenly stops and can't start</p>
  
  <pre><code>[root@backup ~]# service mysql start
  Starting MySQL.170815 09:56:24 mysqld_safe Logging to '/var/lib/mysql/backup.err'.
  170815 09:56:24 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
  ..... ERROR!
  </code></pre>
  
  <p>/var/lib/mysql/backup.err:</p>
  
  <pre><code>170814 06:44:02 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
  2017-08-14  6:44:02 3069880736 [Note] /usr/sbin/mysqld (mysqld 10.1.25-MariaDB) starting as process 3250 ...
  2017-08-14  6:44:02 3069880736 [Note] InnoDB: innodb_empty_free_list_algorithm has been changed to legacy because of small buffer pool size. In order to use backoff, increase buffer pool at least up to 20MB.
  
  2017-08-14  6:44:02 3069880736 [Note] InnoDB: Using mutexes to ref count buffer pool pages
  2017-08-14  6:44:02 3069880736 [Note] InnoDB: The InnoDB memory heap is disabled
  2017-08-14  6:44:02 3069880736 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
  2017-08-14  6:44:02 3069880736 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
  2017-08-14  6:44:02 3069880736 [Note] InnoDB: Compressed tables use zlib 1.2.3
  2017-08-14  6:44:02 3069880736 [Note] InnoDB: Using Linux native AIO
  2017-08-14  6:44:02 3069880736 [Note] InnoDB: Using generic crc32 instructions
  2017-08-14  6:44:02 3069880736 [Note] InnoDB: Initializing buffer pool, size = 128.0M
  2017-08-14  6:44:02 3069880736 [Note] InnoDB: Completed initialization of buffer pool
  2017-08-14  6:44:02 3069880736 [Note] InnoDB: Highest supported file format is Barracuda.
  2017-08-14  6:44:02 3069880736 [Note] InnoDB: Starting crash recovery from checkpoint LSN=2657313375
  2017-08-14  6:44:02 3069880736 [Note] InnoDB: Restoring possible half-written data pages from the doublewrite buffer...
  InnoDB: Set innodb_force_recovery to ignore this error.
  2017-08-14  6:44:02 3069880736 [ERROR] Plugin 'InnoDB' init function returned error.
  2017-08-14  6:44:02 3069880736 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
  2017-08-14  6:44:02 3069880736 [Note] Plugin 'FEEDBACK' is disabled.
  2017-08-14  6:44:02 3069880736 [ERROR] Unknown/unsupported storage engine: InnoDB
  2017-08-14  6:44:02 3069880736 [ERROR] Aborting
  
  Error in my_thread_global_end(): 1 threads didn't exit
  170814 06:44:07 mysqld_safe mysqld from pid file /var/lib/mysql/backup.pid ended
  </code></pre>
  
  <p>Test MySQL:</p>
  
  <pre><code>[root@backup ~]# mysql
  ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111 "Connection refused")
  </code></pre>
  
  <p>/etc/my.cnf :</p>
  
  <pre><code>#
  [client] 
  port = 3306 
  socket = /var/lib/mysql/mysql.sock
  # This group is read both both by the client and the server
  # use it for options that affect everything
  #
  [client-server]
  
  #
  # include all files from the config directory
  #
  !includedir /etc/my.cnf.d
  </code></pre>
  
  <p>/etc/my.cnf.d/server.cnf:</p>
  
  <pre><code>#
  # These groups are read by MariaDB server.
  # Use it for options that only the server (but not clients) should see
  #
  # See the examples of server my.cnf files in /usr/share/mysql/
  #
  
  # this is read by the standalone daemon and embedded servers
  [server]
  
  # this is only for the mysqld standalone daemon
  [mysqld]
  
  #
  # * Galera-related settings
  #
  [galera]
  # Mandatory settings
  #wsrep_on=ON
  #wsrep_provider=
  #wsrep_cluster_address=
  #binlog_format=row
  #default_storage_engine=InnoDB
  #innodb_autoinc_lock_mode=2
  #
  # Allow server to accept connections on all interfaces.
  #
  #bind-address=0.0.0.0
  #
  # Optional setting
  #wsrep_slave_threads=1
  #innodb_flush_log_at_trx_commit=0
  
  # this is only for embedded server
  [embedded]
  
  # This group is only read by MariaDB servers, not by MySQL.
  # If you use the same .cnf file for MySQL and MariaDB,
  # you can put MariaDB-only options here
  [mariadb]
  
  # This group is only read by MariaDB-10.1 servers.
  # If you use the same .cnf file for MariaDB of different versions,
  # use this group for options that older servers don't understand
  [mariadb-10.1]
  </code></pre>
  
  <p>I have already uninstalled MariaDB server and client, then reinstalled it but it still doesn't work. </p>
  
  <pre><code>[root@backup ~]# service mysql restart
   ERROR! MySQL server PID file could not be found!
  Starting MySQL.170815 11:33:12 mysqld_safe Logging to '/var/lib/mysql/backup.err'.
  170815 11:33:12 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
  ..... ERROR!
   ERROR! Failed to restart server.
  [root@backup ~]# mysql
  ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111 "Connection refused")
  </code></pre>
  
  <p>grep "socket"</p>
  
  <pre><code>[root@backup ~]# mysqld --verbose --help | grep "socket"
  2017-08-15 18:05:44 3070110112 [Note] Plugin 'FEEDBACK' is disabled.
                        Buffer length for TCP/IP and socket communication
    --performance-schema-max-socket-classes=#
                        Maximum number of socket instruments.
    --performance-schema-max-socket-instances=#
                        Maximum number of opened instrumented sockets. Use 0 to
                        the slave off the socket once the slave connects. Due to
    --socket=name       Socket file to use for connection
  performance-schema-max-socket-classes                      10
  performance-schema-max-socket-instances                    -1
  socket                                                     /var/lib/mysql/mysql.sock
  </code></pre>
  
  <p>What could possibly be going wrong?</p>