0

Everything was fine until I changed my computer. I'm trying to migrate my database with php artisan migrate but I get this error

  SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = grain and table_name = migrations and table_type = 'BASE TABLE')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:712
    708▕         // If an exception occurs when attempting to run a query, we'll format the error
    709▕         // message to include the bindings with SQL, which will make this exception a
    710▕         // lot more helpful to the developer instead of just the database's errors.
    711▕         catch (Exception $e) {
  ➜ 712▕             throw new QueryException(
    713▕                 $query, $this->prepareBindings($bindings), $e
    714▕             );
    715▕         }
    716▕     }

      +33 vendor frames 
  34  artisan:35
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

Any attempt to interact with the database gives me the same error

this is my .env configuration

    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE=grain
    DB_USERNAME=root
    DB_PASSWORD=
5
  • Do you have mysql set up on this new computer? I.e. can you do mysql -u root in your Terminal/Command Line? Have you run all the appropriate steps, like composer install, etc.? This seems like an issue with your new computer not being configured properly, so you'll have to do some digging to find the exact cause. Commented Jan 3, 2023 at 17:48
  • Regarding "Any attempt to interact with the database gives me the same error": check the connection to your DB via the terminal. Please specify how your database works. Are you using a docker container, a local installation, or something else? Commented Jan 3, 2023 at 17:50
  • Also, remember that before you can perform the migrations themselves, you must have the DB schema itself created. Commented Jan 3, 2023 at 17:57
  • 1
    @slaff.bg yeah but that will trigger another error "SQLSTATE[HY000] [1049] Unknown database" Commented Jan 3, 2023 at 17:58
  • 1
    @TimLewis You are right, the problem actually came from the fact that I changed pc. On the old I was using MAMP and the new XAMPP. Commented Jan 3, 2023 at 18:19

1 Answer 1

0

The problem was because on my old pc I was using MAMP and now I'm using XAMPP so in the database.php file the unix_socket path was wrong.

So go to your my.cnf file and search the socket path then make sur that the socket path is the same as the unix_socket path in your database.php file

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.