0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Laravelでmigatateした時にエラーが出ました。

Posted at

下記のエラーが出ました。

$ php artisan migrate

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

原因

  • データベースを作成せずにコマンドを入力したこと

解決方法

  • mysqlにログインしてデータベースを作成した
  • $ mysql -u root
  • mysql> create database 任意のDB名;
  • mysql> use DB名;
  • mysql> create user ユーザー名 IDENTIFIED BY '任意のパスワード';
  • mysql> grant all privileges on DB名.* to 'ユーザー名';
  • mysql> quit;
  • .envファイルにDB_DATABASE DB_USERNAME DB_PASSWORDをそれぞれ追記した

そして$ php artisan config:cacheを行い設定を反映させ
再度、$ php artisan migrateで解消された。

焦らず順番に行なうようにしていきたい。

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?