Ad Widget

Collapse

Config DB connection error. Cannot connect to the database. No such file or directory

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • AlphonsoDelard
    Junior Member
    • Jun 2022
    • 2

    #1

    Config DB connection error. Cannot connect to the database. No such file or directory

    New installation of Zabbix on an Azure VM

    Upon loading http://**.**.*.**/zabbix/setup.php
    I'm getting an error "Cannot connect to the database. No such file or directory" - on the Configure DB page.

    I'm certain this is probably a sock file issue, but I've set everything up correctly, lengthy details as follows:

    System details:

    O/S Red Hat Enterprise Linux release 8.4 (Ootpa)
    Zabbix 6.0 LTS
    MySQL: 8.0.29

    Installation instructions have been exactly followed as on Download and install Zabbix 6.0 LTS for Red Hat Enterprise Linux 8, MySQL

    Apart from, following the error and extensive research, I've recreated the mysql zabbix user using Native password, as I read on another post this may fix the issue. It hasn't.

    create user 'zabbix'@'localhost' identified with mysql_native_password by '*******'; # (21 char in length including upper/lower case, numbers and special chars (specifically £))
    grant all privileges on zabbix.* to 'zabbix'@'localhost';


    MySQL sock file has been moved to a separate disk that will hold the database files.

    [root@????]# cd /data/mysql
    [root@????]# ls -al mysql.sock srwxrwxrwx. 1 mysql mysql 0 Jun 23 13:15 mysql.sock


    MySQL config details:

    /etc/my.cnf details:

    [client]
    socket=/data/mysql/mysql.sock

    [mysqld]
    datadir=/data/mysql
    #socket=/var/lib/mysql/mysql.sock
    socket=/data/mysql/mysql.sock
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid
    default-authentication-plugin=mysql_native_password

    Zabbix config:

    /etc/zabbix/zabbix_server.conf:

    DBHost=localhost
    DBName=zabbix
    DBUser=zabbix
    DBPassword=**********
    DBSocket=/data/mysql/mysql.sock


    The local zabbix linux user can connect fine to mysql

    [root@????]# su - zabbix

    [zabbix@????]$ mysql -u zabbix -p zabbix
    Enter password:

    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A

    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 193
    Server version: 8.0.29 MySQL Community Server - GPL

    Copyright (c) 2000, 2022, Oracle and/or its affiliates.

    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.

    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

    mysql> show tables;
    +----------------------------+
    | Tables_in_zabbix |
    +----------------------------+
    | acknowledges |
    | actions |


    I've looked in the following logs and can't find any errors.

    /var/log/zabbix/zabbix_server.log
    /var/log/mysqld.log
    /var/log/messages


    Please help me!
  • Answer selected by AlphonsoDelard at 24-06-2022, 15:19.
    Atsushi
    Senior Member
    • Aug 2013
    • 2028

    I think I also needed to set the default socket used by PHP. Try setting mysqli.default_socket in php.ini as shown in the URL below.

    Comment

    • Atsushi
      Senior Member
      • Aug 2013
      • 2028

      #2
      I think I also needed to set the default socket used by PHP. Try setting mysqli.default_socket in php.ini as shown in the URL below.

      Comment

      • AlphonsoDelard
        Junior Member
        • Jun 2022
        • 2

        #3
        Thank you so much Atsushi

        Only one of the entries in php.ini had the new sock file location, amended and Zabbix configured.

        Comment

        Working...