3

I'm trying to connect my laravel project that is running on wsl2 ubuntu to mysql server (with xampp) running on windows 10.

.env file configs

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=test
DB_USERNAME=root
DB_PASSWORD=

when I run a php artisan migrate it gives this error

Illuminate\Database\QueryException  : SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = test and table_name = migrations and table_type = 'BASE TABLE')at /mnt/e/Projects/FT_INV/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669

.

catch (Exception $e) {
   throw new QueryException(
      $query, $this->prepareBindings($bindings), $e

.

Exception trace:

  1   Doctrine\DBAL\Driver\PDO\Exception::("SQLSTATE[HY000] [2002] No such file or directory")
      /mnt/e/Projects/FT_INV/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18

  2   Doctrine\DBAL\Driver\PDO\Exception::new()
      /mnt/e/Projects/FT_INV/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:42
  • One thing I can say is that WSL2 has its [own network](https://superuser.com/a/1679774/30493), and localhost/127.0.0.1 only refers to itself. `$ ip route` (on the WSL2 command line) should tell you what that is. THAT said, I can't connect with WSL2/PHP/PDO either, so if you've solved it, I'd love to know the answer.. – MSpreij Sep 14 '22 at 09:38

0 Answers0