Harris Alam
Harris Alam

Reputation: 11

Magento 2 - SQLSTATE[42S02]: Base table or view not found when running a reindex

I am getting the following error on terminal when running bin/magento indexer:reindex:

***SQLSTATE[42S02]: Base table or view not found: 1146 Table 'catalog_product_index_price_cfg_opt_temp' doesn't exist, query was: DESCRIBE `catalog_product_index_price_cfg_opt_temp.


I have checked the website database and can confirm the table does exist but with no data.

catalog_product_index_price_cfg_opt_tmp table

When I manually run the SQL query (DESCRIBE `catalog_product_index_price_cfg_opt_temp) it created data.

However, when I try re-running the bin/magento indexer:reindex command following this, it removed the data created when running the above SQL command and i still get the same below error on terminal

***SQLSTATE[42S02]: Base table or view not found: 1146 Table 'catalog_product_index_price_cfg_opt_temp' doesn't exist, query was: DESCRIBE `catalog_product_index_price_cfg_opt_temp.


Hopefully you can help me to resolve this. Thank you!

Upvotes: 1

Views: 1140

Answers (1)

UnpassableWizard
UnpassableWizard

Reputation: 1287

Check if you are setting the table prefix correct in app/etc/env.php

...
'db' => [
    'table_prefix' => 'pref_',
    'connection' => [
        'default' => [
            'host' => 'localhost',
            'dbname' => 'magentodb',
            'username' => 'user',
            'password' => 'pass',
            'model' => 'mysql5',
            'engine' => 'innodb',
            'initStatements' => 'SET NAMES utf8;',
            'active' => '1',
        ]
    ]
],
...

And do bin/magento indexer:reset

Upvotes: 0

Related Questions