2017-07-07 125 views
0

我试图用我的Laravel项目附上phpMyAdmin的在我的XAMPP服务器,我失败了,我每次做:发生连接phpMyAdmin的在XAMPP与Laravel项目

php artisan migrate 

此错误:

[PDOException]          
SQLSTATE[HY000] [2002] No such file or directory 
  • 这是我.env文件:

    DB_CONNECTION=mysql 
    DB_HOST=localhost 
    DB_PORT=3306 
    DB_DATABASE=laravel 
    DB_USERNAME=root 
    DB_PASSWORD='' 
    
  • 这是我database.php文件:

    'mysql' => [ 
        'driver' => 'mysql', 
        'host' => 'localhost', 
        'port' => env('DB_PORT', '3306'), 
        'database' => 'laravel', 
        'username' => 'root', 
        'password' => '', 
        'unix_socket' => '/opt/lampp/var/mysql/mysql.sock', 
        'charset' => 'utf8mb4', 
        'collation' => 'utf8mb4_unicode_ci', 
        'prefix' => '', 
        'strict' => true, 
        'engine' => null, 
    
    ], 
    

回答

0

的错误是因为你试图与这无法找到给提供的路径套接字文件连接到MySQL。将路径更改为mysql.sock文件

+0

在您的php.ini文件中更改'mysqli.default_host'指向路径'/ tmp/mysql.sock' –