2013-12-13 50 views
1

只是測試一些代碼,嘗試所有觸發器保存在數據庫中,然後重新創建這些訪問在information_schema.triggers上被拒絕?

drop table if exists triggertemp; 

create table triggertemp like information_schema.TRIGGERS; 

insert into triggertemp (
select * from information_schema.TRIGGERS where TRIGGER_SCHEMA = 'id2target'); 

delete from information_schema.TRIGGERS where TRIGGER_SCHEMA = 'id2target'; 

-- and then to re-create them 
insert into information_schema.TRIGGERS (select * from triggertemp); 

,但我得到拒絕訪問用戶「根」 @「%」數據庫INFORMATION_SCHEMA。現在,我已經爲這個用戶的每個模式授予了所有權限,但仍然沒有任何權限。

我錯過了一個特權?或者這是一個安全的建築,我正在做錯事情?

回答

0

http://dev.mysql.com/doc/refman/5.6/en/information-schema.html說:

只能讀取表的內容,不執行INSERT,UPDATE或DELETE這些操作。

如果你想保留的觸發,然後還原它們,你可以這樣做:

$ mysqldump --triggers --no-create-db --no-create-info --no-data id2target > triggers.sql 

$ mysql id2target < triggers.sql 
+0

可以是用來更改數據後應用只是觸發到目標數據庫?還是會恢復數據庫內容? –

+0

@KellyLarsen,請閱讀[mysqldump文檔](http://dev.mysql.com/doc/refman/5.6/en/mysqldump.html)以瞭解上面顯示的各個選項。我不打算重新輸入現成的信息。 –

+0

我很抱歉。我整個下午都一直在面對同樣的問題,這讓我的腦子變得很髒。明天我會試一試。欣賞幫助:) –