问题
What does Trigger in wrong schema mean ?
DELIMITER $$
CREATE TRIGGER `wordpress_database1`.`insert_user_from_database2` AFTER INSERT ON `wordpress_database2`.`wp_users`
FOR EACH
ROW
BEGIN
INSERT INTO `wordpress_database1`.`wp_users` ( ID, user_login, user_pass, user_nicename, user_email, user_url, user_registered, user_activation_key, user_status, display_name)
VALUES ( New.ID, New.user_login, New.user_pass, New.user_nicename, New.user_email, New.user_url, New.user_registered, New.user_activation_key, New.user_status, New.display_name );
END;$$
回答1:
Trigger needs to be on the same schema as where you are inserting (i.e. you would create the trigger on wordpress_database2
). You can still insert to other schemas. With that simple change, the entire rest of it should work.
来源:https://stackoverflow.com/questions/14823033/mysql-trigger-issue-in-wrong-schema