Find the base image attribute id from eav_attribute.
attr_id = SELECT `attribute_id` FROM `eav_attribute` WHERE `attribute_code` = "image" AND `frontend_label` = "Base" LIMIT 1;
Find all images which having a Base image role.
value = SELECT `value` FROM `catalog_product_entity_varchar` WHERE `attribute_id` = (attr_id);
Find all ids from the media gallery.
gallery = SELECT `value_id` FROM `catalog_product_entity_media_gallery` WHERE `value` IN (value);
Update the media gallery value to 0.
UPDATE `catalog_product_entity_media_gallery_value` SET `disabled` = 0 WHERE `value_id` IN (gallery);
Final query:
UPDATE `catalog_product_entity_media_gallery_value` SET `disabled` = 0 WHERE `value_id` IN (
SELECT `value_id` FROM `catalog_product_entity_media_gallery` WHERE `value` IN (
SELECT `value` FROM `catalog_product_entity_varchar` WHERE `attribute_id` = (
SELECT `attribute_id` FROM `eav_attribute` WHERE `attribute_code` = "image" AND `frontend_label` = "Base" LIMIT 1 ) ) );

