Home > OS >  Laravel SQLSTATE[HY000] [1049] Unknown database PHP artisan migrate
Laravel SQLSTATE[HY000] [1049] Unknown database PHP artisan migrate

Time:10-16

I have setup Laravel before and I have never encountered a Database unknown issue. I am trying to install the default Laravel migration on a new project.

I have already created the database on my server.

I am using MAMP Apache port:80 MYSQL Port: 3306

My env setup looks like this:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=thevinesa
DB_USERNAME=root
DB_PASSWORD=******

When I try to use PHP artisan migrate; I get an error of database unknown

SQLSTATE[HY000] [1049] Unknown database 'thevinesa' (SQL: select * from information_schema.tables where table_schema = thevinesa and table_name = migrations and table_type = 'BASE TABLE') at vendor/laravel/framework/src/Illuminate/Database/Connection.php:703
        699// If an exception occurs when attempting to run a query, we'll format the error
        700// message to include the bindings with SQL, which will make this exception a
        701// lot more helpful to the developer instead of just the database's errors.
        702catch (Exception $e) {
        703throw new QueryException(
        704$query, $this->prepareBindings($bindings), $e
        705▕             );
        706▕         }
        707▕     }
    
           33 vendor frames 
      34  artisan:37
          Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

How can I solve this error

CodePudding user response:

Step 1:

Fire this command inside your project

php artisan optimize:clear

Step 2:

Then start project if in local:

php artisan serve

Database is then connected.

CodePudding user response:

It's an simple error, you still did't created your database in mysql or phpmyadmin named thevinesa

DB_DATABASE=thevinesa

Laravel try to find out the database name thevinesa to connect but they didn't find and database named thevinesa . Try to create database. Then migrate.

php artisan migrate
  • Related