2016-05-31 46 views
1

我們計劃我們的東西遷移到瑞士電信應用雲計算,因此需要導入現有的MySQL轉儲到MariaDB的 - 迄今爲止沒有什麼大不了的......爲什麼我不能導入一個MySQL轉儲觸發器進MariaDB的

但只要導入觸發器,轉儲的導入就會失敗。

例如我有這個單觸發轉儲:

DELIMITER ;; 
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER trg_mytable_insert AFTER INSERT ON mytable FOR EACH ROW 
        BEGIN 

         INSERT INTO mytable_audit (id, fk_X) 
         SELECT a.id, a.fk_X FROM mytable a WHERE a.id = NEW.id; 

        END */;; 
DELIMITER ; 

我觸發這樣導入:

mysql --user xxxxxxx -pxxxxxxx -h 127.0.0.1 -P 13000 CF_E7D2D18F_A20B_4FFF_89A7_XXXXXXXX < trigger.sql 

導致此錯誤:

ERROR 1227 (42000) at line 2: Access denied; you need (at least one of) the SUPER privilege(s) for this operation 

奇怪的是,與liquibase我們能夠用完全相同的用戶創建觸發器。那麼通過mysql CLI需要什麼特殊權限才能導入觸發器?

回答

2
CREATE*/ /*!50017 DEFINER=`root`@`localhost`* 

您會看到這一消息,因爲MariaDB的瑞士電信在雲應用程序不提供SUPER權限,因此你不能設置一個觸發器或視圖中爲不同的用戶運行 - 只有超級用戶可以去做。

請參閱Using MySQL triggers and views in Amazon RDS以解決sed的解決方法。

I recently had an opportunity to migrate a customer from a physical server into Amazon’s RDS environment. In this particular case the customers’ platform makes extensive use of MySQL triggers and views. I came across two significant issues that prevented me from following Amazon’s documentation, which basically states 「use mysqldump」 but doesn’t call out a specific method of dealing with MySQL triggers and views.

mysqldump -h hostname -u username -ppassword –single-transaction database_name | sed -e ‘s/\/\*[^*]*DEFINER=[^*]*\*\///’ | mysql -h hostname -u username -ppassword database_name 
相關問題