LoginSignup
1
0

More than 1 year has passed since last update.

laravelでmigrationが通らなかった時に対応したこと(Illuminate\Database\QueryException )

Posted at

エラーの背景

以下のようなエラーが出ました。

$ php artisan migrate
Illuminate\Database\QueryException 

  SQLSTATE[HY000] [1049] Unknown database 'laravel-todo_db' (SQL: select * from information_schema.tables where table_schema = laravel-todo_db and table_name = migrations and table_type = 'BASE TABLE')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:745
    741▕         // If an exception occurs when attempting to run a query, we'll format the error
    742▕         // message to include the bindings with SQL, which will make this exception a
    743▕         // lot more helpful to the developer instead of just the database's errors.
    744▕         catch (Exception $e) {
  ➜ 745▕             throw new QueryException(
    746▕                 $query, $this->prepareBindings($bindings), $e
    747▕             );
    748▕         }
    749▕     }

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

mysqlが接続されていないことが原因でした。

有益な記事

基本mysql接続はこの記事で接続ができてエラーが解決しました。
https://yaba-blog.com/laravel-db/

このエラーが出たらこの記事も参考にする

MySQL Workbenchを入れておく

phpadminは基本実務で使わないので、MySQL Workbenchをダウンロードします。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0