Ad Widget

Collapse

Database error: Error connecting to database.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • N.S
    Junior Member
    • Jul 2018
    • 8

    #1

    Database error: Error connecting to database.

    Hi,
    I am having a problem at zabbix web interface, it won't connect to the database as I receive this error: Error connecting to database. Here you'll find attached two screenshots from both files:
    /etc/zabbix/zabbix_server.conf
    /usr/share/zabbix/conf/zabbix.conf.php
    I can't tell what is wrong.
    Any help?
  • kernbug
    Senior Member
    • Feb 2013
    • 330

    #2
    Hi,

    Can you connect to the database from the console?

    Comment

    • N.S
      Junior Member
      • Jul 2018
      • 8

      #3
      Hi, yes. Here's a caption that shows the connection:
      Attached Files

      Comment

      • Atsushi
        Senior Member
        • Aug 2013
        • 2028

        #4
        I am setting as follows.
        And, in the pg_hba.conf, the connection authentication method setting from the local network is changed from ident to md5.

        Code:
        $DB['TYPE']     = 'POSTGRESQL';
        $DB['SERVER']   = 'localhost';
        $DB['PORT']     = '0';
        $DB['DATABASE'] = 'zabbix';
        $DB['USER']     = 'zabbix';
        $DB['PASSWORD'] = 'password';

        Comment

        • N.S
          Junior Member
          • Jul 2018
          • 8

          #5
          I restarted the whole thing and it worked with MYSQL database. Thanks anyway.

          Comment

          • Ashenta
            Junior Member
            • Jan 2020
            • 1

            #6
            Thanks for the advice although it didn't fully sort the problem the below did though.

            cd /
            find . -name "pg_hba.conf" '#to find the file location

            I had this at the bottom of the file


            # TYPE DATABASE USER ADDRESS METHOD

            # "local" is for Unix domain socket connections only
            local all all md5
            # IPv4 local connections:
            host all all 127.0.0.1/32 md5
            # IPv6 local connections:
            host all all ::1/128 ident
            # Allow replication connections from localhost, by a user with the
            # replication privilege.
            local replication all peer
            host replication all 127.0.0.1/32 ident
            host replication all ::1/128 ident

            I changed it to


            # TYPE DATABASE USER ADDRESS METHOD

            # "local" is for Unix domain socket connections only
            local all all md5
            # IPv4 local connections:
            host all all 127.0.0.1/32 md5
            # IPv6 local connections:
            host all all ::1/128 md5
            # Allow replication connections from localhost, by a user with the
            # replication privilege.
            local replication all md5
            host replication all 127.0.0.1/32 md5


            Any changes to config files will need the service to be restarted in order to accept the changes unless in /proc directory

            systemctl restart postgresql #use tab key to list the full name.

            psql -U zabbix -d zabbix -h localhost

            success!

            Also, SELinux can stop lots of things from working, keep that in mind if the above doesn't work for you.

            Comment

            Working...