How to change attribute code in Magento 1/2.

UPDATE `eav_attribute`
    SET  `eav_attribute`.`attribute_code` = "TO"
    WHERE `eav_attribute`.`attribute_code` = 'FROM';

So, for example:

UPDATE `eav_attribute`
    SET  `eav_attribute`.`attribute_code` = "main_color"
    WHERE `eav_attribute`.`attribute_code` = 'color';