title: zabbix server connecting to mariadb host: can't connect to local MySQL server through socket
body: <p>I have a Dockerized Zabbix server (3.4) connecting to a CentOS 7 host w/ Mariadb.</p>
  
  <p>This one works fine:</p>
  
  <pre><code># zabbix_get -s &lt;ipOfRemoteHost&gt; -p 10050 -k mysql.version
  mysql  Ver 15.1 Distrib 5.5.56-MariaDB, for Linux (x86_64) using readline 5.1
  </code></pre>
  
  <p>This one does not:</p>
  
  <pre><code># zabbix_get -s &lt;ipOfRemoteHost&gt; -p 10050 -k mysql.ping
  mysqladmin: connect to server at 'localhost' failed
  error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)'
  Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
  </code></pre>
  
  <p>From <code>/etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf</code>:</p>
  
  <pre><code>UserParameter=mysql.version,mysql -V
  UserParameter=mysql.ping,HOME=/etc/zabbix mysqladmin ping | grep -c alive
  </code></pre>
  
  <p>It does read the .my.cnf in the HOME dir, when change <code>host=localhost</code> to <code>host=127.0.0.1</code> I get:</p>
  
  <pre><code># zabbix_get -s &lt;ipOfRemoteHost&gt; -p 10050 -k mysql.ping
  mysqladmin: connect to server at '127.0.0.1' failed
  error: 'Can't connect to MySQL server on '127.0.0.1' (13)'
  Check that mysqld is running on 127.0.0.1 and that the port is 3306.
  You can check this by doing 'telnet 127.0.0.1 3306'
  </code></pre>
  
  <p>Also tried adding the username and password directly in the command, but same result:</p>
  
  <pre><code>UserParameter=mysql.ping,mysqladmin -uroot --password="mypassword" ping | grep -c alive
  </code></pre>
  
  <p>Running that command on the host works fine:</p>
  
  <pre><code>mysqladmin -uroot --password="mypassword"  ping | grep -c alive
  1
  </code></pre>
  
  <p>The agent itself seems to run fine:</p>
  
  <pre><code>$ sudo -u zabbix zabbix_agentd -t mysql.ping
  mysql.ping                                    [t|1]
  </code></pre>
  
  <p>Socket is available:</p>
  
  <pre><code># ls -l /var/lib/mysql/mysql.sock
  srwxrwxrwx. 1 mysql mysql 0 Nov  5 18:01 /var/lib/mysql/mysql.sock
  </code></pre>
  
  <p>Process details:</p>
  
  <pre><code># ps -ef | grep mysqld
  mysql     3218     1  0 18:01 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
  mysql     3488  3218 99 18:01 ?        06:08:26 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock
  systemd+  6547  6530  0 Oct31 ?        00:06:15 mysqld --character-set-server=utf8 --collation-server=utf8_bin
  </code></pre>
  
  <p>Any suggestions?</p>
  
  <p>Note: don't think it is relevant but just in case, on the host I also have a Dockerized mysql running on port 3307</p>