title: Can't remotely connect to MySQL error (13) with PHP script, connecting through CLI works
body: <p>I have looked at around 50 of the same question on here, but none of them seem to be fixing my problem. I can't remotely connect to my MySQL database through a php script, <strong>but!!</strong> connecting with  <code>mysql -u admin -p -h 172.16.2.93</code> works.</p>
  
  <h2>Here is the code I'm using</h2>
  
  <pre><code>&lt;?php
  session_start();
  
  // initializing variables
  $username = "";
  $email    = "";
  $errors = array(); 
  
  $dbhost = "172.16.2.93";
  $dbuser = "admin";
  $dbpass = "mariadb";
  $dbname = "registration";
  
  // connect to the database
  $db = mysqli_connect("$dbhost", "$dbuser", "$dbpass", "$dbname") or die(mysql_error());
  </code></pre>
  
  <h2>The Error</h2>
  
  <p>And I'm getting the following error in <code>/var/log/httpd/access_log</code> when I access the website the script is connected to: </p>
  
  <p><code>[:error] [pid 14797] [client 172.16.2.143:55201] PHP Warning:  mysqli_connect(): (HY000/2003): Can't connect to MySQL server on '172.16.2.93' (13) in /var/www/html/server.php on line 15</code></p>
  
  <h2>Things I've tried</h2>
  
  <ul>
  <li><p>Changing <code>bind-address</code> to <code>bind-address=0.0.0.0</code> and <code>#bind-address</code></p></li>
  <li><p>Turning off all firewalls</p></li>
  <li><p>Running the command <code>setsebool httpd_can_network_connect=1</code></p></li>
  <li><p>Disabling selunix in <code>/etc/selinux/config</code></p></li>
  </ul>
  
  <p>Edit: The problem seems to have been fixed. After creating the user <code>remote@%</code> with <code>mysql_native_password</code> I was able to access the database through the script.</p>