Search code examples
databaselaravellaravel-artisan

Artisan says database not found


I'm working on a brand new laravel application for learning laravel.

I've done the following (I'm following this tutorial):

  1. Created new application using laravel new test_project_2
  2. Setup the .env file
  3. Created a database called laravel
  4. Run php artisan migrate

This is my .env file: enter image description here

This is what I get: enter image description here

As you can see, I can use the "laravel" database perfectly well when I'm logged into Mariadb via terminal. The website also renders absolutely fine. I did run the SQL command - SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE' but I got the message ERROR 1054 (42S22): Unknown column 'laravel' in 'where clause'

Note - I've worked on other dummy laravel projects last week and didn't face any problems, although admittedly I'm not sure if I ran the php artisan migrate command for those (wasn't required, but I might have run it just cause I kept seeing it).

  • Why is this problem happening?
  • How do I fix it?

Solution

  • Solved this by changing the DB_HOST values from 127.0.0.1 to localhost.

    Anyone know why this works? Beats the heck out of me.