1

my magento2 is reading mariadb server and database is connected to that, I am trying o use mysql instead but I had no luck, it does not recognize the database at all although I have added the following:

    'db' => [
    'connection' => [
        'indexer' => [
            'host' => 'localhost',
            'dbname' => 'm2',
            'username' => 'user',
            'password' => 'xxx',
            'model' => 'mysql4',
            'engine' => 'innodb',
            'active' => '1',
            'persistent' => NULL
        ],
        'default' => [
            'host' => 'localhost',
            'dbname' => 'm2',
            'username' => 'user',
            'password' => 'xxx',
            'model' => 'mysql4',
            'engine' => 'innodb',
            'active' => '1'
        ]
    ],
    'table_prefix' => ''

I also tried using a new user name and password for only mysql to make it understand to read from there but still it is connecting to mariadb instead.

How can I switch it to mysql? my mysql version is 5.7.28 and my magento version is 2.3.1

In Abstract.php line 128:

SQLSTATE[HY000] [1049] Unknown database 'm2'

how can I switch so it understands to read from mysql server instead of mariadb?

Fatal error: Uncaught TypeError: Argument 1 passed to Magento\Framework\Setup\De
claration\Schema\Db\SchemaBuilder::processReferenceKeys() must be of the type ar
ray, null given, called in C:\wamp64\www\scosche-industries\vendor\magento\frame
work\Setup\Declaration\Schema\Db\SchemaBuilder.php on line 127 and defined in C:
\wamp64\www\scosche-industries\vendor\magento\framework\Setup\Declaration\Schema
\Db\SchemaBuilder.php:137
Stack trace:
#0 C:\wamp64\www\scosche-industries\vendor\magento\framework\Setup\Declaration\S
chema\Db\SchemaBuilder.php(127): Magento\Framework\Setup\Declaration\Schema\Db\S
chemaBuilder->processReferenceKeys(NULL, Object(Magento\Framework\Setup\Declarat
ion\Schema\Dto\Schema))
#1 C:\wamp64\www\scosche-industries\vendor\magento\framework\Setup\Declaration\S
chema\SchemaConfig.php(66): Magento\Framework\Setup\Declaration\Schema\Db\Schema
Builder->build(Object(Magento\Framework\Setup\Declaration\Schema\Dto\Schema))
#2 C:\wamp64\www\scosche-industries\vendor\magento\framework\Setup\Declaration\S
chema\UpToDateDe in C:\wamp64\www\scosche-industries\vendor\magento\framework\Se
tup\Declaration\Schema\Db\SchemaBuilder.php on line 137
1
  • which Magento version, you have using? Open Source version OR community version
    – Amit Bera
    Jan 7, 2020 at 7:27

1 Answer 1

0

I think you have used wrong connection for indexer.

 'indexer' => [
            'host' => 'localhost',
            'dbname' => 'm2',
            'username' => 'user',
            'password' => 'xxx',
            'model' => 'mysql4',
            'engine' => 'innodb',
            'active' => '1',
            'persistent' => NULL
        ],

Magento open source version does not have different connection for indexer.It is worked in Commerce version means sperate resource Connection.

Connection Might be like:

    'db' => [
        'table_prefix' => '',
        'connection' => [
            'default' => [
                'host' => 'localhost',
                'dbname' => 'm2',
                'username' => 'user',
                'password' => 'xxx',
                'model' => 'mysql4',
                'engine' => 'innodb',
                'initStatements' => 'SET NAMES utf8;',
                'active' => '1'
            ]
        ]
    ],
    'resource' => [
        'default_setup' => [
            'connection' => 'default'
        ]
    ]

Also, put proper mysql username and password and the mysql user should have read r/write connection at database.

15
  • I did not touch it manually thats how it was created while I have installed it , what i did was I installed with a raw database from scratch. an empty database. I have the paid version. does that mean open source version?
    – Nickool
    Jan 7, 2020 at 7:44
  • are you saying I remove my indexer array and only keep default?
    – Nickool
    Jan 7, 2020 at 7:46
  • You have paid for Magento source code ? If yes, then it should be commerce version or Cloud version
    – Amit Bera
    Jan 7, 2020 at 7:46
  • yes I have cloud version
    – Nickool
    Jan 7, 2020 at 7:47
  • and cloud works with mariadb and now my localhost is doing it but I wanna do mysql
    – Nickool
    Jan 7, 2020 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.