Ad Widget

Collapse

Fresh Zabbix 7.2.2 : MySQL - Cannot Connect to the Database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • carlos.pena
    Junior Member
    • Sep 2024
    • 7

    #1

    Fresh Zabbix 7.2.2 : MySQL - Cannot Connect to the Database


    Hi,
    I followed the procedure step by step. My Infra: rhel 9.4 server / mysql

    When I use my browser with the url : https://myserver.mydomain.com/zabbix , I'm getting next screen:

    Click image for larger version

Name:	image.png
Views:	466
Size:	44.7 KB
ID:	497669

    My SSL certificate is working ok, and I'm able to open a session on mysql ( mysql -uroot -p ) and use zabbix database.
    My firewall and selinux are disabled.

    Could you give somes clues.

    Thank you.​
  • Blevar
    Member
    • Jan 2025
    • 68

    #2
    Hi,

    Try running:
    Code:
    systemctl restart zabbix-server
    or
    Code:
    systemctl status zabbix-server
    If the server status is other than running than it might be caused by some errors with the DB. Maybe importing the schema didnt work? If so run
    Code:
    zcat /usr/share/zabbix/sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
    Restart the server and try web api again.

    Comment


    • carlos.pena
      carlos.pena commented
      Editing a comment
      Thanks Blevar, but that didn't work.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #3
    I'm able to open a session on mysql ( mysql -uroot -p ) and use zabbix database.
    Are you able to use that database with user zabbix? (mysql -uzabbix -p) ?

    Comment


    • carlos.pena
      carlos.pena commented
      Editing a comment
      Yes, I'm.

      [nag@xxx ~]$ mysql -uzabbix -p
      Enter password:
      Welcome to the MySQL monitor. Commands end with ; or \g.
      Your MySQL connection id is 179
      Server version: 8.0.36 Source distribution

      Copyright (c) 2000, 2024, 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> use zabbix;
      Reading table information for completion of table and column names
      You can turn off this feature to get a quicker startup with -A

      Database changed
      mysql> show tables;
      +----------------------------+
      | Tables_in_zabbix |
      +----------------------------+
      | acknowledges |
      | actions |
  • imadedwis234
    Junior Member
    • Jan 2025
    • 3

    #4
    Hello Cyber,

    I'm facing this issue too.
    Fresh install with 7.2.2 version Zabbix, couldn't connect to database. I have tried connect from another machine to database server and no have problem, status connected, I could show databases, use database or show tables. I'm using Mysql version 8.0.36 for Linux on aarch64.
    Is this bug on this version ?

    Thank you

    Comment

    • tim.mooney
      Senior Member
      • Dec 2012
      • 1427

      #5
      For carlos.pena : is the "using SSL" part of the original error message a potential clue? It has been a very long time since I did a fresh install of the Zabbix front-end (web interface), so I'm not certain about how or if it presents an option to disable encryption for the database connection, but when you're using MySQL/MariaDB/Percona on the same host and you're connecting through the UNIX socket, you don't need (and I think don't want) encryption for that connection. It's not going over the network at all so there's no danger of eavesdropping. If your database server were on a different host, then a network-based connection would be required and using TLS encryption and proper certs would be highly advisable. It's only when both database & app are on the same server and they're configured to use the local socket that encryption isn't needed.

      For the front end (web interface), you obviously need to have all the correct PHP extensions loaded. The previous screen should have verified that you have them all I think. Was everything good on that screen?

      If you run

      Code:
      php -i
      (can be run as a normal user) and look at the mysqli and mysqlnd section of the output, is the value for mysqli.default_socket the correct location that MySQL server is using to create the socket file? There have been a few reports on these forums in the past of PHP's extension not using the correct / updated location for where MySQL server is configured to actually create the UNIX socket. That seems like it was a misconfiguration only for certain distros packages, though, and I don't think that affects RHEL (I'm using RHEL 9.x as my server too, but I'm not on 7.x yet). Probably worth checking though.

      Comment


      • carlos.pena
        carlos.pena commented
        Editing a comment
        Yes, everything is good on checking screen, and the location for the socket is Ok too. Thanks Tim.
    Working...