Zabbix – How to Fix Connection to Wrong Database

zabbix

I have installed Zabbix on a CentOS 7 remote server, but I can't get it running.

I took a look at /var/log/zabbix/ and I get the following error:

1951:20190116:044530.834 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: YES)

Now, the problem is that I DO have a database for zabbix, but it is named zabbixdb, not zabbix (as in the error message)

I tried to re-run the setup page and entered zabbixdb, but still nothing. Also, the /etc/zabbix/web/zabbix.conf.php is correctly configured

global $DB;

$DB['TYPE']     = 'MYSQL';
$DB['SERVER']   = '127.0.0.1';
$DB['PORT']     = '0';
$DB['DATABASE'] = 'zabbixdb';
$DB['USER']     = 'zabbixuser';
$DB['PASSWORD'] = '[my_pass_here]';

// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = '';

$ZBX_SERVER      = '127.0.0.1';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = 'SV Zabbix Server';

$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;

I doubled checked and zabbixdb DOES exist and user zabbixuser has all the privileges over it.

GRANT ALL PRIVILEGES ON `zabbixdb`.* TO 'zabbixuser'@'localhost'                                                  

What others reasons could be? Somehow zabbix has access, because it has created tables in the zabbixdb, but can't use them.


EDIT: The Solution

As it turns out, I followed the tutorial's instructions blindly. Thank you @Zatarra for the solution.

My problem was that when I wrote the DB's credentials, I wrote them exactly at the top of the file, while they where also present at a lower level, and thus, when read, were overwritten in memory.

I solved this by modifying the variables present at the lower level in the file.

Best Answer

Try to restart the service and check if it still tries to use the zabbix database in the logs. If it does check if you have duplicate DBName entries in zabbix_server.conf

grep DBName /etc/zabbix/zabbix_server.conf

And are you getting the error for zabbix web or for zabbix server? As far as I see you are pasting the web configuration, maybe you are looking in the wrong place.