title: CodeIgniter Message: mysqli::real_connect(): (HY000/2002): Connection timed out giving error in server
body: <p>I create a project in Codeigniter version 3.1.1. It's working fine on local. But when I upload it into the server then giving error:</p>
  <blockquote>
  <p>A PHP Error was encountered</p>
  <p>Severity: Warning</p>
  <p>Message: mysqli::real_connect(): (HY000/1045): Access denied for user   'myprac_usr'@'localhost' (using password: YES)</p>
  <p>Filename: mysqli/mysqli_driver.php</p>
  <p>Line Number: 201</p>
  </blockquote>
  <p>Backtrace:</p>
  <blockquote>
  <p>File: /var/www/html/myproject/application/controllers/User.php</p>
  <p>Line: 10</p>
  <p>Function: __construct</p>
  <p>File: /var/www/html/myproject/index.php</p>
  <p>Line: 315</p>
  <p>Function: require_once</p>
  </blockquote>
  <pre><code>$db['default'] = array(
  'dsn'   =&gt; '',
  'hostname' =&gt; 'hostip',
  'username' =&gt; 'mydbusername',
  'password' =&gt; 'mydbpassword',
  'database' =&gt; 'mydbusername',
  'dbdriver' =&gt; 'mysqli',
  'dbprefix' =&gt; '',
  'pconnect' =&gt; FALSE,
  'db_debug' =&gt; (ENVIRONMENT !== 'production'),
  'cache_on' =&gt; FALSE,
  'cachedir' =&gt; '',
  'char_set' =&gt; 'utf8',
  'dbcollat' =&gt; 'utf8_general_ci',
  'swap_pre' =&gt; '',
  'encrypt' =&gt; FALSE,
  'compress' =&gt; FALSE,
  'stricton' =&gt; FALSE,
  'failover' =&gt; array(),
  'save_queries' =&gt; TRUE
  );  
  </code></pre>
  <p>I have also changed the host name with &quot;localhost&quot; instead of host ip.</p>
  <p>Mysql version- 5.6.27</p>
  <p>PHP version- 5.5.36</p>