Ad Widget

Collapse

Can't connect to local MySQL server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cmowse
    Junior Member
    • Jan 2014
    • 3

    #1

    Can't connect to local MySQL server

    Hello,
    after my first zabbix installation. i have the following problem:

    According to the dashboard the local mysql-DB is down,
    but in real it's running (zabbix & DB).

    Unfortunately I couldn't see a configuration problem.
    Could anybody help me?


    zabbix-server-2.2.1-1.el6.x86_64
    -----------------------------------

    #from /var/log/zabbix/zabbix_agentd.log:
    error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)'
    Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!


    #ls -la /var/lib/mysql/mysql.sock
    srwxrwxrwx. 1 mysql mysql 0 13. Jan 01:48 /var/lib/mysql/mysql.sock
  • cmowse
    Junior Member
    • Jan 2014
    • 3

    #2
    #cat /etc/my.cnf
    [client]
    user=xxxxxxx
    password=xxxxxxx
    socket=/var/lib/mysql/mysql.sock
    [mysqld]
    bind-address=127.0.0.1
    port=3306
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    user=mysql
    # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0
    [mysqld_safe]
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid
    socket=/var/lib/mysql/mysql.sock

    #cat /etc/zabbix/zabbix_server.conf|grep DB|grep -v \#
    DBHost=localhost
    DBName=zabbix
    DBUser=zabbix
    DBPassword=xxxxxx
    DBSocket=/var/lib/mysql/mysql.sock
    DBPort=3306

    Comment

    • cmowse
      Junior Member
      • Jan 2014
      • 3

      #3
      solved

      The problem based on usage of SELinux, which must be configured accordingly.

      Grep the related error message in audit.log add them to a custom policy (mypol) for SELinux:

      $grep zabbix_agent /var/log/audit/audit.log|grep mysql.sock|tail -1| audit2allow -M mypol
      $semodule -i mypol.pp

      Comment

      Working...