Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting error mysqli::real_connect(): (HY000/2002): No such file or directory when I try to access my project on live server

I had uploaded my website to server and then I tried to access, but the code igniter returns me that error that I don't find any answer. Why is this happening?

My config database is set like:

$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'netservice',
'password' => '*********',
'database' => 'valedastrutas',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE,
);
like image 838
William Avatar asked Apr 28 '15 19:04

William


3 Answers

MySQL connection driver does not get any meaningful server at the location of localhost. So use,

'hostname' => '127.0.0.1' 

rather than

'hostname' => 'localhost'
like image 194
Subarata Talukder Avatar answered Nov 01 '22 01:11

Subarata Talukder


I've got this error

mysqli::real_connect(): (HY000/2002): No such file or directory

from PhpMyAdmin running on my Mac Mojave, with MySQL server also running on my Mac.

Fixed it by editing PhpMyAdmin/config.inc.php and changed the line:

$cfg['Servers'][$i]['host'] = 'localhost';

to

$cfg['Servers'][$i]['host'] = '127.0.0.1';
like image 15
Michal J Figurski Avatar answered Nov 01 '22 01:11

Michal J Figurski


in phpmyadmin version 5.1.0 all lang., the config. file is located in libraries/config.default.php

do the following change:

$cfg['Servers'][$i]['host'] = 'localhost';

to

$cfg['Servers'][$i]['host'] = '127.0.0.1';
like image 6
Zaid Mohammed Avatar answered Nov 01 '22 01:11

Zaid Mohammed