Summer Sale! All accounts are 50% off this week.

etrainerspy's avatar

Getting an error on the command: php artisan migrate

This is the message that I am getting:

[Illuminate\Database\QueryException] SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = blog_ testing and table_name = migrations)

[PDOException] SQLSTATE[HY000] [2002] No such file or directory

I am using the "Laravel 5.4 from Scratch" tutorial, Episode 22: Testing 101. I am encountering this problem when having 3.29 minutes left on the video.

Can someone help me?

0 likes
17 replies
Mittensoff's avatar

You have a space in your table schema - blog_testing. Check your database config file or your migrations to find that space.

etrainerspy's avatar

I do not believe that is the problem. The space you see has to do with the terminal output to a new line.

Screenbeetle's avatar

Morning etrainerspy

Some questions:

  1. Do you have a database (sorry :-)
  2. If you are migrating a test database then does your non test database migrate ok?
  3. Do you have your .env file set up correctly?
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=database-name
DB_USERNAME=homestead
DB_PASSWORD=secret
etrainerspy's avatar

Yikes! I just deleted all of the tables from my non test database and tried to migrate. I am getting the same error message:

[Illuminate\Database\QueryException] SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = projLearn and table_name = migrations)

[PDOException] SQLSTATE[HY000] [2002] No such file or directory

Where should I look next to solve the problem?

Snapey's avatar

in your .env file use 127.0.0.1 instead of localhost so that pdf connection is via IP rather than socket

you should not need to do this but it sounds like you have a socket configuration issue

jeff-h's avatar

@visheshchanana if you mean literally creating the database, I'd suggest the app Sequel Pro if you're on macOS or something like it if you're on Windows.

mmusante's avatar

I got this error on macos sierra when using the built-in php (version 5.6.30). When I switched to 7.1.9 the error went away.

SANTI1111's avatar

PLEASE, BE SURE YOU HAVE THE CORRECT DB_PORT ON THE .env FILE

clayton191's avatar

SANTI1111 is correct. I spent a couple of hours trying every possible suggested fix on the internet, and nothing had worked until I looked at the DB_PORT in the .env file. Wamperver was using 3308 instead of the default 3306. I was FINALLY usable to get php artisan migrate to run!

turesg's avatar

I changed DB_HOST=mysql to DB_HOST=127.0.0.1 in .env file It worked.

lara332987's avatar

I've tried everything. No luck. php artisan migrate gives me ` Illuminate\Database\QueryException

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for database failed: Name or service not known (Connection: mysql, SQL: select table_name as name, (data_length + index_length) as size, table_comment as comment, engine as engine, table_collation as collation

running most recent version of lando

kokoshneta's avatar

@brockness That is a completely different issue, in a different environment. Please create a separate thread for your question, rather than digging up a six year old, unrelated question.

Please or to participate in this conversation.