2016-06-21 29 views
1

私は最初にcakephp 3アプリケーション用にローカルのmysqlデータベースを使用しました。私はcakephp3アプリケーションをデプロイする途中ですので、RDS MySqlインスタンスを作成し、それをMySqlワークベンチに接続し、以前に持っていたデータベースをRDSデータベースにコピーしました。私のapp.phpの設定はそうです。私はAWSコンソールでCakePHP3 AWS RDSデータベースのアプリケーションエラー

if (!defined('RDS_HOSTNAME')) { 
    define('RDS_HOSTNAME', $_SERVER['myendpoint.us-west-1.rds.amazonaws.com']); 
    define('RDS_USERNAME', $_SERVER['myusername']); 
    define('RDS_PASSWORD', $_SERVER['mypassword']); 
    define('RDS_DB_NAME', $_SERVER['my_db']); 
} 

その後app.phpファイルのデータソース]セクションで

'Datasources' => [ 
    'default' => [ 
     'className' => 'Cake\Database\Connection', 
     'driver' => 'Cake\Database\Driver\Mysql', 
     'persistent' => false, 
     'host' => RDS_HOSTNAME, 
     /** 
     * CakePHP will use the default DB port based on the driver selected 
     * MySQL on MAMP uses port 8889, MAMP users will want to uncomment 
     * the following line and set the port accordingly 
     */ 
     //'port' => 'non_standard_port_number', 
     'username' => RDS_USERNAME, 
     'password' => RDS_PASSWORD, 
     'database' => RDS_DB_NAME, 
     'encoding' => 'utf8', 
     'timezone' => 'UTC', 
     'flags' => [], 
     'cacheMetadata' => true, 
     'log' => false, 

を持っている私の定数を定義する

それは私がRDSインスタンスへの接続を持っていると言います。しかし、登録/ログインしようとするとCakePHPの内部エラーが発生します。私はエラーログをチェックし、私はerror.logファイルでこれを見つけました。

2016-06-20 17:25:35 Error: [PDOException] SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO) 
Request URL: /users/register 
Referer URL: http://localhost:8765/ 
Client IP: 127.0.0.1 
Stack Trace: 
#0 /home/danielparkk/Desktop/SubReminder/vendor/cakephp/cakephp/src/Database/Driver/PDODriverTrait.php(47): PDO->__construct('mysql:host=;por...', NULL, NULL, Array) 
#1 /home/danielparkk/Desktop/SubReminder/vendor/cakephp/cakephp/src/Database/Driver/Mysql.php(90): Cake\Database\Driver\Mysql->_connect('mysql:host=;por...', Array) 

私が間違っていることを理解できませんか?私が持っているデータベースのローカルコピーに戻ると、すべての機能が必要です。どんな助けもありがとう。

===================

2016-06-21T00:22:17.815360Z 24 [Note] Access denied for user 'root'@'108-83-57-226.lightspeed.irvnca.sbcglobal.net' (using password: NO) 
2016-06-21T00:34:38.776248Z 26 [Note] Aborted connection 26 to db: 'subscriptions_db' user: 'root' host: '108-83-57-226.lightspeed.irvnca.sbcglobal.net' (Got timeout reading communication packets) 
2016-06-21T00:34:42.872265Z 25 [Note] Aborted connection 25 to db: 'subscriptions_db' user: 'root' host: '108-83-57-226.lightspeed.irvnca.sbcglobal.net' (Got timeout reading communication packets) 

インスタンス用のAWSコンソールでエラーログを読み込むと、この出力が得られます。率直に言って、これはRDSを使った初めてのことなので、どういう意味か分かりませんが、他の人に役立つかもしれません。

答えて

0

$ _SERVERには不要です。私もconnect cakephp 3.01 AWS RDSは私のコードです。

'Datasources' => [ 
    'default' => [ 
     'className' => 'Cake\Database\Connection', 
     'driver' => 'Cake\Database\Driver\Mysql', 
     'persistent' => false, 
     'host' => 'yourendpoint.us-west-1.rds.amazonaws.com', 
     'username' => 'rdsusername', 
     'password' => 'rdspassword', 
     'database' => 'rdsdatabasename', 
     'encoding' => 'utf8', 
     'timezone' => 'UTC', 
     'cacheMetadata' => true, 

     /** 
     * Set identifier quoting to true if you are using reserved words or 
     * special characters in your table or column names. Enabling this 
     * setting will result in queries built using the Query Builder having 
     * identifiers quoted when creating SQL. It should be noted that this 
     * decreases performance because each query needs to be traversed and 
     * manipulated before being executed. 
     */ 
     'quoteIdentifiers' => false, 

     /** 
     * During development, if using MySQL < 5.6, uncommenting the 
     * following line could boost the speed at which schema metadata is 
     * fetched from the database. It can also be set directly with the 
     * mysql configuration directive 'innodb_stats_on_metadata = 0' 
     * which is the recommended value in production environments 
     */ 
     //'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'], 
    ] 
    ], 
関連する問題