Конфигурация базы данных Cake PHP 4.0 - PullRequest
1 голос
/ 11 января 2020
    '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)

Я хочу прибегнуть к этой ошибке и найти решение, чтобы устранить ошибку. Вся помощь приветствуется. BAKE!

1 Ответ

1 голос
/ 11 января 2020

Настройки в app.php являются, так сказать, глобальными настройками по умолчанию, и их можно переопределить, загрузив дополнительные файлы конфигурации, что обычно делается для обеспечения более конкретной c конфигурации для различных сред, локальных / разработки , staging, production et c.

Начиная с Cake PHP 4, шаблон приложения по умолчанию генерирует и загружает дополнительный файл конфигурации с именем app_local.php , которая переопределяет некоторые параметры, включая конфигурацию источника данных.

Короче говоря, установите учетные данные в config/app_local.php вместо config/app.php.

См. Также

...