はじめまして、yaminonakaと申します。
PHPでWEBアプリケーションを開発したく勉強中です。
「PHP初めてのフレームワーク Laravel 5.5/5.4/5.3 〜ステップ1」という本を読みながら勉強を始めたばかりの超初心者です。
56ページ 6. マイグレーションを 実 行 (テーブル 作成)
で行き詰まってしまいました。
ネットで情報を探したんですが、
キーワードすら見当がつかず、こちらにて質問させて頂きます。
よろしくお願い申し上げます。
###発生している問題・エラーメッセージ
[Illuminate\Database\QueryException]
SQLSTATE[HY000] [1045] Access denied for user 'hoge'@'localhost' (using password: NO) (SQL: sele
ct * from information_schema.tables where table_schema = c9 and table_name = migrations)
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'hoge'@'localhost' (using password: NO)
###試したこと
本の例を参考に以下のようなマイグレーションを作成し、
//------------------------------------------------- // /cms/database/migrations/2017_09_19_080547_create_books_table.php // ------------------------------------------------- <?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateBooksTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('books', function (Blueprint $table) { $table->increments('id'); $table->string('item_name'); $table->integer('item_number'); $table->integer('item_amount'); $table->datetime('published'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('books'); } } -------------------------------------------------
Cloud9のプロンプトで
php artisan migrate
と実行しましたが、
上記のようなエラーで前に進めません。
なお、本の指示に従って以下のようにしています。
###.envの修正点
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=c9 DB_USERNAME=hoge DB_PASSWORD=
###AppServiceProvider.phpの修正点
<?php namespace App\Providers; use Illuminate\Support\ServiceProvider; use Illuminate\Support\Facades\Schema; //追加 class AppServiceProvider extends ServiceProvider { /** * Bootstrap any application services. * * @return void */ public function boot() { Schema::defaultStringLength(191); //追加 } /** * Register any application services. * * @return void */ public function register() { // } }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/09/19 22:39