Mysql – GTID consistency: CREATE TEMPORARY TABLE and DROP TEMPORARY TABLE can only be executed outside transactional context

google-cloud-platformMySQL

My Magento version is 2.2.3. We are using a Google Cloud SQL 2nd gen instance.

Facing error while run indexing command

General error: 1787 Statement violates GTID consistency: CREATE
TEMPORARY TABLE and DROP TEMPORARY TABLE can only be executed outside
transactional context. These statements are also not allowed in a
function or trigger because functions and triggers are also considered
to be multi-statement transactions., query was: CREATE TEMPORARY TABLE
IF NOT EXISTS catalog_product_index_eav_temp LIKE
catalog_product_index_eav_tmp

Best Answer

Seems Magento does use forbidden statements for GTID to do the indexing.

Because Google Cloud Second Generation instances intrinsically do use GTID, Magento cannot work with this kind of instance. There is a post in Github in which many users are experiencing your same problem (probably because an update?).

In that post, it suggests you might want to use SQL First Generation instead. The user called "klarre1" commented this change solved the same problem for him.