CakePHP 4.0 数据库配置
CakePHP 4.0 database configuration
'default' => [
'className' => Connection::class,
'driver' => Mysql::class,
'persistent' => false,
'username' => 'root',
'password' => 'root',
'port' => '8889',
'database' => 'rajasthan_skill_development',
'timezone' => 'UTC',
/**
* For MariaDB/MySQL the internal default changed from utf8 to utf8mb4, aka full utf-8 support, in CakePHP 3.6
*/
//'encoding' => 'utf8mb4',
/**
* If your MySQL server is configured with `skip-character-set-client-handshake`
* then you MUST use the `flags` config to set your charset encoding.
* For e.g. `'flags' => [\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4']`
*/
'flags' => [],
'cacheMetadata' => true,
'log' => false,
/*
* 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'],
],
上面的代码 config/app.php 文件所在的位置,以便使用 MySQL 启用数据库 我无法加载数据库并使用该配置连接 MySQL 数据库我在哪里找到你问的错误:
error file
/Applications/MAMP/htdocs/sd/sd/vendor/cakephp/cakephp/src/Database/Driver.php
SQLSTATE[HY000] [1045] Access denied for user 'my_app'@'localhost' (using password: YES)
我想利用那个错误找到解决错误的方法。
感谢所有帮助。烘烤!
app.php
中的设置可以说是default/global设置,可以通过加载额外的配置文件来覆盖它们,通常这样做是为了为不同的环境提供更具体的配置, local/development、分期、制作等
从 CakePHP 4 开始,默认应用程序模板生成 loads an additional configuration file named app_local.php
,它会覆盖一些设置,包括数据源配置。
长话短说,在 config/app_local.php
而不是 config/app.php
中设置凭据。
另见
您需要检查是否有 config/app_local.php
它会覆盖 config/app.php
中的设置。
'default' => [
'className' => Connection::class,
'driver' => Mysql::class,
'persistent' => false,
'username' => 'root',
'password' => 'root',
'port' => '8889',
'database' => 'rajasthan_skill_development',
'timezone' => 'UTC',
/**
* For MariaDB/MySQL the internal default changed from utf8 to utf8mb4, aka full utf-8 support, in CakePHP 3.6
*/
//'encoding' => 'utf8mb4',
/**
* If your MySQL server is configured with `skip-character-set-client-handshake`
* then you MUST use the `flags` config to set your charset encoding.
* For e.g. `'flags' => [\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4']`
*/
'flags' => [],
'cacheMetadata' => true,
'log' => false,
/*
* 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'],
],
上面的代码 config/app.php 文件所在的位置,以便使用 MySQL 启用数据库 我无法加载数据库并使用该配置连接 MySQL 数据库我在哪里找到你问的错误:
error file
/Applications/MAMP/htdocs/sd/sd/vendor/cakephp/cakephp/src/Database/Driver.php
SQLSTATE[HY000] [1045] Access denied for user 'my_app'@'localhost' (using password: YES)
我想利用那个错误找到解决错误的方法。 感谢所有帮助。烘烤!
app.php
中的设置可以说是default/global设置,可以通过加载额外的配置文件来覆盖它们,通常这样做是为了为不同的环境提供更具体的配置, local/development、分期、制作等
从 CakePHP 4 开始,默认应用程序模板生成 loads an additional configuration file named app_local.php
,它会覆盖一些设置,包括数据源配置。
长话短说,在 config/app_local.php
而不是 config/app.php
中设置凭据。
另见
您需要检查是否有 config/app_local.php
它会覆盖 config/app.php
中的设置。