前提・実現したいこと
このサイト
https://www.inet-solutions.jp/technology/laravel-tutorial/
に沿ってlaravelを触れてみようと思ったのですが、migrateがうまく出来ないため、それの対処法を知りたいです。
環境はlaravel5.6です。xamppを使ってます。Windows10。
発生している問題・エラーメッセージ
C:\xampp\htdocs\blog>php artisan migrate Illuminate\Database\QueryException : SQLSTATE[HY000] [1049] Unknown database 'blog' (SQL: select * from information_schema.tables where table_schema = blog and table_name = migrations) at C:\xampp\htdocs\blog\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664 660| // If an exception occurs when attempting to run a query, we'll format the error 661| // message to include the bindings with SQL, which will make this exception a 662| // lot more helpful to the developer instead of just the database's errors. 663| catch (Exception $e) { > 664| throw new QueryException( 665| $query, $this->prepareBindings($bindings), $e 666| ); 667| } 668|
試したこと
config\database.phpや.envなどの設定が大事と書いてあり、試したができなかった。
###config\database.phpの変更箇所
database,username,passwordを変更した
'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'blog'), //もともとblogではなかった 'username' => env('DB_USERNAME', 'root'), //もともとrootではなかった 'password' => env('DB_PASSWORD', 'password'), //もともとpasswordではなかった。良くわからない
//のでmysqlと同じパスワードにした
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
###.envの変更箇所
database,username,passwordが変更箇所、上記のconfig\database.phpと同じ名前になるように変更した。
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=blog DB_USERNAME=root DB_PASSWORD=password
回答1件
あなたの回答
tips
プレビュー