【发布时间】:2017-07-02 13:57:34
【问题描述】:
在 Drupal 中,配置数据库设置(数据库、用户名、密码、主机等)的最佳实践是什么?
在sites/default/default.settings.php 中声明如下:
/**
* Database settings:
*
* The $databases array specifies the database connection or
* connections that Drupal may use. Drupal is able to connect
* to multiple databases, including multiple types of databases,
* during the same request.
*
* One example of the simplest connection array is shown below. To use the
* sample settings, copy and uncomment the code below between the @code and
* @endcode lines and paste it after the $databases declaration. You will need
* to replace the database username and password and possibly the host and port
* with the appropriate credentials for your database system.
*
* The next section describes how to customize the $databases array for more
* specific needs.
*
* @code
* $databases['default']['default'] = array (
* 'database' => 'databasename',
* 'username' => 'sqlusername',
* 'password' => 'sqlpassword',
* 'host' => 'localhost',
* 'port' => '3306',
* 'driver' => 'mysql',
* 'prefix' => '',
* 'collation' => 'utf8mb4_general_ci',
* );
* @endcode
*/
$databases = array();
但是如果你的开发环境和生产环境有不同的数据库设置呢?
【问题讨论】: