質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Amazon RDS

Amazon RDSは、米アマゾン社が提供しているRDBMSサービス。クラウド上でのリレーショナルデータベースの構築および運用が可能です。MySQL/PostgreSQL/Oracle/SQL Serverのインストールを容易にすることができます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

Amazon EC2

Amazon EC2は“Amazon Elastic Compute Cloud”の略称です。Amazon Web Services(AWS)の一部であり、仮想化されたWebサーバーのコンピュータリソースをレンタルできるサービスです。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Laravel 5

Laravel 5は、PHPフレームワークLaravelの最新バージョンで、2014年11月に発表予定です。ディレクトリ構造がが現行版より大幅に変更されるほか、メソッドインジェクションやFormRequestの利用が可能になります。

Q&A

解決済

4回答

3332閲覧

php artisan migrateを実行するとエラーになる

kurotaku6

総合スコア8

Amazon RDS

Amazon RDSは、米アマゾン社が提供しているRDBMSサービス。クラウド上でのリレーショナルデータベースの構築および運用が可能です。MySQL/PostgreSQL/Oracle/SQL Serverのインストールを容易にすることができます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

Amazon EC2

Amazon EC2は“Amazon Elastic Compute Cloud”の略称です。Amazon Web Services(AWS)の一部であり、仮想化されたWebサーバーのコンピュータリソースをレンタルできるサービスです。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Laravel 5

Laravel 5は、PHPフレームワークLaravelの最新バージョンで、2014年11月に発表予定です。ディレクトリ構造がが現行版より大幅に変更されるほか、メソッドインジェクションやFormRequestの利用が可能になります。

0グッド

0クリップ

投稿2019/11/07 14:58

編集2019/11/08 05:22

MAMP環境で開発していたLaravelプロジェクトをAWSにデプロイする際に、
EC2上で php artisan migrateを実行するとエラーが発生するので解決したい

状況としてはLaravelプロジェクトはブラウザで表示されている。

エラー表示

Illuminate\Database\QueryException : SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = and table_name = migrations and table_type = 'BASE TABLE') at /var/www/html/namilog/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| Exception trace: 1 PDOException::("SQLSTATE[HY000] [2002] No such file or directory") /var/www/html/namilog/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70 2 PDO::__construct("mysql:unix_socket=/Applications/MAMP/tmp/mysql/mysql.sock;dbname=", "namilog", "password", []) /var/www/html/namilog/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70 Please use the argument -v to see more details.

と表示され実行できません。
unix_socketあたりが問題なのでしょうか?

.envは以下で設定しています。

env

1DB_CONNECTION=mysql 2DB_HOST=<エンドポイント> 3DB_PORT=3306 4DB_DATABASE= 5DB_USERNAME=<マスターユーザー名> 6DB_PASSWORD=<パスワード>

マイグレーション対象ファイルは以下です。

<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateUsersTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->integer('stance')->default(1); $table->integer('board')->default(1); $table->string('introduction')->nullable(); $table->string('image_path')->nullable(); $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); $table->rememberToken(); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('users'); } }
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateSpotsTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('spots', function (Blueprint $table) { $table->increments('id'); $table->integer('user_id')->unsigned(); $table->string('name'); $table->string('place'); $table->string('body'); $table->timestamps(); // 外部キーを設定する $table->foreign('user_id')->references('id')->on('users'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('spots'); } }
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateDiariesTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('diaries', function (Blueprint $table) { $table->increments('id'); $table->integer('spot_id')->unsigned(); $table->integer('user_id')->unsigned(); $table->string('title'); $table->integer('score'); $table->integer('condition'); $table->integer('size'); $table->string('body'); $table->string('image_path')->nullable(); $table->timestamps(); // 外部キー設定 $table->foreign('spot_id')->references('id')->on('spots'); $table->foreign('user_id')->references('id')->on('users'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('diaries'); } }
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateCommentsTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('comments', function (Blueprint $table) { $table->increments('id'); $table->integer('user_id')->unsigned(); $table->integer('diary_id')->unsigned(); $table->string('body'); $table->timestamps(); //外部キー $table->foreign('user_id')->references('id')->on('users'); $table->foreign('diary_id')->references('id')->on('diaries'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('comments'); } }

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

sola-msr

2019/11/07 18:00

マイグレーション対象のファイル等も記載したほうがいいかと
kurotaku6

2019/11/08 05:23

マイグレーションファイル追加しました!
guest

回答4

0

自己解決

.envファイルを更新した後にphp artisan config:cacheを実行すると解決できました。
参考にした記事はこちらです。
https://qiita.com/kawax/items/ea881a6c18b8d4e94d83

投稿2019/11/11 00:31

kurotaku6

総合スコア8

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

EC2に繋ぎたいというのに、MAMP という文字列が見えるのは明らかにおかしい。

bash

1PDO::__construct("mysql:unix_socket=/Applications/MAMP/tmp/mysql/mysql.sock;dbname=", "namilog", "password", [])

投稿2019/11/08 12:20

編集2019/11/08 12:20
退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

kurotaku6

2019/11/08 17:49

そこを変更したいんですがdatabase.phpや.envの設定を変更しても変更されません。 変更する点が間違っているのでしょうか?
退会済みユーザー

退会済みユーザー

2019/11/09 02:41

envをいじったら、artisan cache:clear をしなければいけません。
kurotaku6

2019/11/09 06:18

php artisan cache:clear を実行後でもmysql:unix_socket=/Applications/MAMP/tmp/mysql/mysql.sock;dbname= のpathが変更されないので変更点は別なのでしょうか?
退会済みユーザー

退会済みユーザー

2019/11/09 06:19

まさかとは思いますが、php artisan cache:clear コレをMac上で実行したりしてませんか?
guest

0

EC2からDBへの接続自体はできていますか。

投稿2019/11/08 07:15

pims-tak

総合スコア39

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

kurotaku6

2019/11/08 17:50

接続自体はできている状態です。
guest

0

.envファイルのDB設定を確認してください。

投稿2019/11/07 15:04

JinwonKim

総合スコア312

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

kurotaku6

2019/11/07 15:12

DB_CONNECTION=mysql DB_HOST=<エンドポイント> DB_PORT=3306 DB_DATABASE= DB_USERNAME=<マスターユーザー名> DB_PASSWORD=<パスワード> となっています。
JinwonKim

2019/11/08 14:18

mysql接続情報を記入してください。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問