Pregunta

Just testing some code, trying to save all the triggers in a database then re-create them

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);

But I get Access denied for user 'root'@'%' to database information_schema. Now I've granted every privilege on every schema for this user, but still nothing.

have I missed a privilege? Or is this a built in safety and I'm going about things wrong?

¿Fue útil?

Solución

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

you can only read the contents of tables, not perform INSERT, UPDATE, or DELETE operations on them.

If you want to preserve the triggers and then restore them you could do this:

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

$ mysql id2target < triggers.sql
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top