Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLSTATE[HY000] [2002] No such file or directory in yii2

I use ubuntu 16.04.
PHP Version 7.0.4-7ubuntu2.
Apache/2.4.18 (Ubuntu) .
PHP extension: mysqli (in phpmyadmin Written).

I got Upgrade my ubuntu from 15.10 to 16.04 and I have this error:

My project correctly run in my server but I can't run that in my os:

Database Exception – yii\db\Exception
SQLSTATE[HY000] [2002] No such file or directory
↵
Caused by: PDOException
SQLSTATE[HY000] [2002] No such file or directory

in /var/www/html/iicitySite/vendor/yiisoft/yii2/db/Connection.php at line 579
like image 281
Saltern Avatar asked Apr 29 '16 05:04

Saltern


1 Answers

Changing "localhost" to "127.0.0.1" as your host

return [
    'components' => [
        'db' => [
            'class' => 'yii\db\Connection',    
            'dsn' => 'mysql:host=127.0.0.1;dbname=abc',
            'username' => 'root',
            'password' => '',
            'charset' => 'utf8',
        ],
like image 68
vijay nathji Avatar answered Sep 20 '22 14:09

vijay nathji