Click here to Skip to main content
15,936,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to change MySQL session variable (i.e, SQL_mode, max_allowed_packet etc) for different user accounts. i have two users sam@localhost and joe@localhost i need to set different MySQL session variable values for both the users (OR) Is there any way to auto call a procedure or sql once the user logged on. so that i can set session variable (i.e, SET SESSION sql_mode = 'modes';) in the procedure. once the user logged on it will set automatically by calling. is this possible??

What I have tried:

i had tried something like this but init_connect doesn't works and also when i restart MySQL service its gets reset.

SET @@sql_mode = CASE CURRENT_USER()
WHEN 'test1@%' THEN 'TRADITIONAL'
WHEN 'test2@localhost' THEN ''
ELSE @@sql_mode
END;

SET GLOBAL init_connect =
"SET @@sql_mode = CASE CURRENT_USER()
WHEN 'test1@localhost' THEN 'TRADITIONAL'
WHEN 'test2@localhost' THEN ''
ELSE @@sql_mode
END;";
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900