I’m try to use trigger on mysql to replicate user on the same server but with different database.
That my request SQL :
CREATE TRIGGER `insert_user_from_test1` AFTER INSERT ON `wordpress_test1`.`wp_users`
FOR EACH ROW BEGIN
INSERT INTO `wordpress_test2`.`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;
And i get that error :
#1046 - No database selected
If you are writing that trigger by executing mysql from the command line tool and haven’t selected the database/schema, then you need to specify/select the database/schema first.
So try first executing this command:
Also you can try to specify the database/schema name along with the trigger name: