-
-
Save makeittotop/9d255d2a425450953281d4bd0ca511ba to your computer and use it in GitHub Desktop.
Change TRIGGERS DEFINER in MySQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
## Create mysql triggers dump | |
## We add DROP TRIGGER IF EXISTS with option --add-drop-trigger | |
## This option is supported only by mysqldump as supplied with MySQL Cluster. It is not available when using MySQL Server 5.5. | |
## If you don't need password dont use -p option. | |
## | |
mysqldump -u <USERNANME> -p --routines --add-drop-trigger --no-create-info --no-data --no-create-db --skip-opt <database> > outputfile.sql | |
## | |
## Change old DEFINER with sed command | |
## Or use your prefered editor to do that | |
## Exemple : `olduser`@`%` -> `newuser`@`localhost` | |
## | |
sed -i -e 's/OLD_DEFINER/NEW_DEFINER/g' outputfile.sql | |
## | |
## Import all new triggers in the database | |
## If you don't need password dont use -p option. | |
## | |
mysql -u <USER> -p <DATABASE_NAME> < outputfile.sql | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment