Ad Widget

Collapse

Error connecting to database: Access denied for user 'zabbix'@'localhost' to database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jaydeep
    Junior Member
    • Sep 2016
    • 16

    #1

    Error connecting to database: Access denied for user 'zabbix'@'localhost' to database

    Hi,

    I have created one VM with Ubuntu 14.04 LTS and trying to test zabbix v3.2 on it. While configuring it thru frontend web setup, it is giving me error : Error connecting to database: Access denied for user 'zabbix' @ 'localhost' to database 'zabbixdb'

    I have given the database name as zabbixdb. Also tried to connect to MySQL directly on Linux command line which is getting thru with the password but while checking thru web setup it gives error - access denied.

    Can anyone help to resolve this issue.

    Thanks in advance.

    Jaydeep
  • SBO
    Zabbix Certified Specialist
    Zabbix Certified Specialist
    • Sep 2015
    • 226

    #2
    This is a mysql error.
    Your user seems to be incorrectly set up, either the password is not the good one, most likely the rights are not the good one.

    You need to give the user zabbix privileges to access the zabbixdb database.

    Comment

    • okelet
      Junior Member
      • Sep 2016
      • 18

      #3
      I normally use these sentences to create the user and database, if the web interface and the Zabbix server is in the same host (if not, you will have to replace localhost with the corresponding IP address or something like 19.168.0.%):

      Code:
      mysql -u root -p
      use mysql;
      CREATE DATABASE `zabbix_db`;
      GRANT ALL PRIVILEGES ON `zabbix_db`.* TO `zabbix_user`@'localhost' IDENTIFIED BY 'XXXXXXXXX';
      FLUSH PRIVILEGES;

      Comment

      • mulbzh
        Senior Member
        • Nov 2014
        • 115

        #4
        where did you put this information ? which file ?

        Comment

        • okelet
          Junior Member
          • Sep 2016
          • 18

          #5
          These are the MySQL commands to create the user and database with the permissions needed.

          Comment

          • asteroidyorkton
            Member
            • Aug 2016
            • 53

            #6
            Check if username and password, DB IP and DB port is correct in /usr/share/zabbix/conf/zabbix.conf.php and /etc/zabbix/zabbix_server.conf

            That's a MySQL error. Fix that.

            In Mysql
            Create user 'zabbix'@'%' identified by 'XXX';
            GRANT ALL PRIVILEGES ON `zabbix`.* TO 'zabbix'@'%'

            If zabbix_user is your username, just make sure you update the files correctly.

            In your case, instead of %, you're using localhost. That means you can connect to it from the database server only. Is the database and zabbix server and zabbix frontend in the same server? If its separate, create account as [email protected](zabbix server IP) or zabbix@%(anywhere).
            Last edited by asteroidyorkton; 21-09-2016, 21:55.

            Comment

            • jaydeep
              Junior Member
              • Sep 2016
              • 16

              #7
              Hi,
              thanks for your feedback.
              I have simply followed the steps as mentioned in the Zabbix installation document manual available online.
              Below are the commands executed while installing:
              $ sudo mysql -uroot -pxxxxx
              mysql> create database zabbixdb character set utf8 collate utf8_bin;
              mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbixuser';
              mysql> quit;
              sudo zcat create.sql.gz | mysql -uroot -pxxxxx zabbixdb

              Also pleas note once again that while I connect to myslq from command line within linux server, the password is working ok. But the same is not working ok while I try to use thru online frontend setup for completing the final configuration.

              Comment

              • asteroidyorkton
                Member
                • Aug 2016
                • 53

                #8
                Did you check the files I mentioned? Did you update the username, password, IP in the files In zabbix.conf.php -> that is the file your frontend uses to connect to DB. Without updating this there is no use.

                Access denied for user 'zabbix' @ 'localhost' to database 'zabbixdb'
                That means in that config file, it is set to use username zabbix.

                But you created different user name...
                GRANT ALL PRIVILEGES ON `zabbix_db`.* TO `zabbix_user`@'localhost' IDENTIFIED BY 'XXXXXXXXX';
                That means you created account zabbix_user and gave privileges to zabbix_user on zabbix_db.* database.

                In the last post, you're saying you used this... Which command did you really run? In the first post, you created zabbix_db database. Now you've created zabbixdb database and you're giving privilges to zabbix.* database which doesn't exist. and now you've created zabbix account.
                grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbixuser';
                That means you created zabbix account and gave priviliges to zabbix.* database which you haven't created.

                grant all privileges on DATABASE_NAME.*(all tables) to USERNAME@IP/HOSTNAME identified by password. I hope it made sense.

                Just run these command on your mysql once so its a clean install. It is okay to have Database name and username as same. You tried to change it without knowing what is what and that's when you messed up.

                mysql -uroot -p (Login with root username and password)
                show databases;
                drop database zabbix_db;
                drop database zabbixdb;
                drop user zabbix_user@localhost;
                drop user zabbix@localhost;
                create database zabbix_db character set utf8 collate utf8_bin;
                grant all privileges on zabbix_db.* to zabbix@localhost identified by 'YOUR_PaSSw0rd';
                quit;

                zcat create.sql.gz | mysql -uroot -pYOUR_PaSSw0rd zabbix_db

                vi /usr/share/zabbix/conf/zabbix.conf.php (if its empty, then find the file, try this command to find it. locate zabbix.conf.php)
                Change password and Change database to zabbix_db

                vi /etc/zabbix/zabbix_server.conf (if its empty, then edit the in /usr/local/etc/zabbix_agentd.conf or locate zabbix_agentd.conf)
                Change password and Change DBName to zabbix_db

                That should get everything setup. The rest are in the documentation, follow it exactly as it shows. Don't make any changes you don't understand. First get it working, then search how to change whatever you want. Restart zabbix_server once everything is complete, last step.

                No more spoon feeding. Google and learn the rest
                Last edited by asteroidyorkton; 22-09-2016, 22:41.

                Comment

                • wiseguytr
                  Junior Member
                  • Jun 2019
                  • 2

                  #9
                  Today I had the same problem and the solution was easier than I though it would be.

                  sudo zcat create.sql.gz | mysql -uroot -pxxxxx zabbixdb actually asks for your db password (in this case: Password). Not your localhost root password.

                  Comment

                  • amirkhan4379
                    Junior Member
                    • Mar 2020
                    • 1

                    #10
                    HI every one i'm new to this application i need some help..

                    I trying to install zabbix 4.0 on ubunto 18.04
                    i created DATABASE SCHEMA after that load the Zabbix database schema to the database which i created with the below commands
                    cd /usr/share/doc/zabbix-server-mysql
                    zcat create.sql.gz | mysql -u zabbix -p zabbixdb
                    Enter password:
                    ERROR 1045 (28000): Access denied for user 'zabbix'@'localhost' (using password: YES)

                    can anyone please help me to solve this issue.

                    Comment

                    • Atsushi
                      Senior Member
                      • Aug 2013
                      • 2028

                      #11
                      Hi amirkhan4379,

                      Did you create an account on MySQL after creating a database with create database? Try to specify the account and password specified when executing the grant.

                      Zabbix is being downloaded over 4 000 000 times every year for a reason. Download and install Zabbix for free and try it yourself!

                      Comment

                      • Kroot
                        Junior Member
                        • Mar 2020
                        • 1

                        #12
                        netstat -tulpn | grep 10051
                        Look if your zabbix-server port is in LISTEN mode, maybe there is some firewall issue

                        Comment

                        • jaida1978
                          Junior Member
                          • Mar 2020
                          • 7

                          #13
                          Originally posted by Kroot
                          netstat -tulpn | grep 10051
                          Look if your zabbix-server port is in LISTEN mode, maybe there is some firewall issue auto clicker
                          I connect to myslq from command line within linux server, the password is working ok. But the same is not working ok while I try to use thru online frontend setup for completing the final configuration
                          Last edited by jaida1978; 27-03-2020, 09:26.

                          Comment

                          • mcdee
                            Junior Member
                            • Jun 2020
                            • 2

                            #14
                            Originally posted by jaida1978

                            I connect to myslq from command line within linux server, the password is working ok. But the same is not working ok while I try to use thru online frontend setup for completing the final configuration
                            I just updated to 5.0 and had the same problem. The update process deleted the Database PW for the user in zabbix_server.conf. I had to add the DBPassword entry again, that solved the issue for me. After that, the setup could complete.
                            Hope this helps someone.

                            Comment

                            • exkg
                              Senior Member
                              Zabbix Certified Trainer
                              Zabbix Certified Specialist
                              • Mar 2007
                              • 718

                              #15
                              Hi Guys, I think a good stating point will be our documentation (not only to MySQL):





                              []s,
                              Luciano
                              --
                              Luciano Alves
                              www.zabbix.com
                              Brazil | México | Argentina | Colômbia | Chile
                              Zabbix Performance Tuning

                              Comment

                              Working...