Connect to mysql server running on windows from wsl2 ubuntu

Viewed 244

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
0 Answers
Related