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

  • Filter
  • Time
  • Show
Clear All
new posts

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


    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.


    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.


      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.%):

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


        where did you put this information ? which file ?


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


            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 [email protected]%(anywhere).
            Last edited by asteroidyorkton; 21-09-2016, 21:55.


              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 [email protected] 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.


                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 [email protected] 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 [email protected]/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 [email protected];
                drop user [email protected];
                create database zabbix_db character set utf8 collate utf8_bin;
                grant all privileges on zabbix_db.* to [email protected] identified by 'YOUR_PaSSw0rd';

                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.



                No announcement yet.