title: MySQL denies access with correct credentials (Zabbix 4.0)
body: <p>I've installed Zabbix 4.0 on Apache2 with a MySQL database. I have created a user called <code>zabbix</code> with a password <code>zabbix</code>, and followed the instructions <a href="https://www.zabbix.com/download?zabbix=4.4&amp;os_distribution=ubuntu&amp;os_version=18.04_bionic&amp;db=mysql&amp;ws=apache" rel="nofollow noreferrer">here</a>.</p>
  
  <p>I can log into MySql via the CLI as user <code>zabbix</code> and write to the tables in the <code>zabbix</code> database - which means, my credentials are good.</p>
  
  <p>My Zabbix configuration file looks like this:</p>
  
  <pre><code>&lt;?php
  // Zabbix GUI configuration file.
  global $DB;
  
  $DB['TYPE']       = 'MYSQL';
  $DB['SERVER']     = 'localhost';
  $DB['PORT']       = '3306';
  $DB['DATABASE']   = 'zabbix';
  $DB['USER']       = 'zabbix';
  $DB['PASSWORD']   = 'zabbix';
  
  // Schema name. Used for IBM DB2 and PostgresSQL.
  $DB['SCHEMA'] = '';
  
  $ZBX_SERVER       = '192.168.0.100';
  $ZBX_SERVER_PORT  = '10051';
  $ZBX_SERVER_NAME  = 'Test';
  
  $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
  </code></pre>
  
  <p>The <code>zabbix_server.log</code> shows</p>
  
  <pre><code>1296:20200214:070924.785 database is down: reconnecting in 10 seconds
  1296:20200214:070934.786 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: YES)`
  </code></pre>
  
  <p>which would indicate the permissions are wrong. </p>
  
  <p>The <code>error.log</code> in MySQL shows the same:</p>
  
  <pre><code>2020-02-14T07:10:14.791188Z 13 [Note] Access denied for user 'zabbix'@'localhost' (using password: YES)
  </code></pre>
  
  <p><strong>I have tried:</strong></p>
  
  <ul>
  <li>Changing the password</li>
  <li>Created a new user and granted it all privileges</li>
  <li>Checked for the anonymous ' ' user (it's not there)</li>
  <li>Changing the port (<code>0</code> is the default, tried changing the MySql port to 3000, 3500, 3306)</li>
  <li>Got rid of the <code>127.0.1.1</code> entry in my <code>/etc/hosts</code></li>
  <li>Changed the <code>$DB['SERVER']</code> to <code>127.0.0.1</code> and <code>192.168.0.100</code></li>
  <li>Reinstalled everything from scratch, including Ubuntu and LAMP - and I got to the exact same error.</li>
  </ul>
  
  <p>What else could it be? It's a plain error message that the credentials are wrong. It's just that they are <em>not</em> wrong.</p>
  
  <p><strong>Versions:</strong></p>
  
  <p><code>mysql -V</code> shows <code>Ver 14.14 Distrib 5.7.29, for Linux (x86_64) using  EditLine wrapper</code></p>
  
  <p><code>zabbix_server --version</code> shows <code>zabbix_server (Zabbix) 4.0.17
  Revision a528a0a4bc 28 January 2020, compilation time: Jan 30 2020 10:22:22</code></p>
  
  <p>Running on <strong>Ubuntu 18.04.4 LTS</strong></p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>mysql&gt; show grants for 'zabbix'@'localhost';
  +------------------------------------------------------------+
  | Grants for zabbix@localhost                                |
  +------------------------------------------------------------+
  | GRANT USAGE ON *.* TO 'zabbix'@'localhost'                 |
  | GRANT ALL PRIVILEGES ON `zabbix`.* TO 'zabbix'@'localhost' |
  +------------------------------------------------------------+
  2 rows in set (0.00 sec)
  </code></pre>