ZABBIX Forums  

Go Back   ZABBIX Forums > Zabbix Discussions and Feedback > Zabbix Help

Reply
 
Thread Tools Display Modes
  #1  
Old 21-09-2016, 13:39
jaydeep jaydeep is offline
Junior Member
 
Join Date: Sep 2016
Posts: 16
Thumbs down 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
Reply With Quote
  #2  
Old 21-09-2016, 13:57
SBO SBO is offline
Zabbix Certified Specialist
Zabbix certified specialist
 
Join Date: Sep 2015
Location: France
Posts: 196
Default

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.
Reply With Quote
  #3  
Old 21-09-2016, 14:42
okelet okelet is offline
Junior Member
 
Join Date: Sep 2016
Posts: 18
Default

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;
Reply With Quote
  #4  
Old 21-09-2016, 16:26
mulbzh mulbzh is offline
Member
 
Join Date: Nov 2014
Posts: 97
Default

where did you put this information ? which file ?
Reply With Quote
  #5  
Old 21-09-2016, 16:40
okelet okelet is offline
Junior Member
 
Join Date: Sep 2016
Posts: 18
Default

These are the MySQL commands to create the user and database with the permissions needed.
Reply With Quote
  #6  
Old 21-09-2016, 21:18
asteroidyorkton asteroidyorkton is offline
Member
 
Join Date: Aug 2016
Posts: 53
Default

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 zabbix@10.1.1.1(zabbix server IP) or zabbix@%(anywhere).

Last edited by asteroidyorkton; 21-09-2016 at 22:55.
Reply With Quote
  #7  
Old 22-09-2016, 09:25
jaydeep jaydeep is offline
Junior Member
 
Join Date: Sep 2016
Posts: 16
Thumbs down

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.
Reply With Quote
  #8  
Old 22-09-2016, 11:10
asteroidyorkton asteroidyorkton is offline
Member
 
Join Date: Aug 2016
Posts: 53
Default

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 at 23:41.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:56.