mysql Trigger issue in wrong schema

☆樱花仙子☆ 提交于 2020-01-02 10:03:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!