Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Some modules, such as uc_views and site_user_list, create database views. These db views cause site migration to fail with the following error:
Importing database using command: mysql --defaults-file=/dev/fd/3 site_620
Database import failed: ERROR 1227 (42000) at line 5119: Access denied; you need the SUPER privilege for this operation
An error occurred at function : drush_provision_mysql_provision_deploy
The lines in the mysqldump file where the importing fails is:
--
-- Final view structure for view `site_user_list_view`
--
/*!50001 DROP TABLE `site_user_list_view`*/;
/*!50001 DROP VIEW IF EXISTS `site_user_list_view`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`w_annertech`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `site_user_list_view` AS select distinct `u`.`uid` AS `@uid`,`u`.`name` AS `@name`,`u`.`picture` AS `@picture` from `users` `u` where ((`u`.`uid` <> 0) and (`u`.`status` = 1)) */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
I even tried doing a 'grant all' on the aegir root user and the site's db user, but couldn't get it to work. In the end I dropped the views in the source database, migrated the site and then recreated the views.
Comment | File | Size | Author |
---|---|---|---|
#21 | provision-881496-mysql-views-migration-6.x-1.x-bgm.patch | 1.05 KB | bgm |
#15 | provision-881496-mysql-views-migration-6.x-1.x.patch | 1.36 KB | Steven Jones |
#15 | provision-881496-mysql-views-migration-7.x-2.x.patch | 1.36 KB | Steven Jones |
#9 | mysql.provision.patch | 1.31 KB | attiks |
Comments
Comment #1
adrian CreditAttribution: adrian commentedThe issue seems to be with the definer bit -
http://stackoverflow.com/questions/154332/how-can-i-use-mysqldump-to-rep...
Comment #2
adrian CreditAttribution: adrian commentedit seems the only option is for us to modify the dump after it has been created, or even more painfully as we import it
Comment #3
adrian CreditAttribution: adrian commentedIt may also help if the modules use the full definition for views.
ie: http://drupalcode.org/viewvc/drupal/contributions/modules/site_user_list...
Should be something like 'CREATE OR REPLACE DEFINER CURRENT_USER SQL SECURITY DEFINER VIEW '.
or something.
Comment #4
omega8cc CreditAttribution: omega8cc commentedThere is a dirty workaround I used with 100% success, see http://groups.drupal.org/node/65128#comment-194963
Comment #5
pcambrasuscribe
Comment #6
pcambraI have half of workaround here, but I haven't tried adrian suggestion yet (instead of blablablah should be drop view sentences)
http://drupal.org/node/855528
Comment #7
jaybhancock CreditAttribution: jaybhancock commentedsubscribe.
Comment #8
Zengoo CreditAttribution: Zengoo commentedsubscribe
Comment #9
attiks CreditAttribution: attiks commentedIncluded a patch that uses sed to change/remove the problematic lines, it works here, but I'm not sure if the version numbers are the same for all mysql's installs.
Comment #10
anarcat CreditAttribution: anarcat commentedI don't like the sed into tmpfiles. Isn't there an option to mysqldump that does this better?
Also keep in mind you can chain multiple sed commands in one shot, no need to call sed multiple times.
Comment #11
attiks CreditAttribution: attiks commentedAFAIK there's no option in mysqldump, i looked around but couldn't find anything. I'm not even sure if all versions of mysql (> 5) use the same syntax for the commands
What do you suggest to use if not a tmp file?
Comment #12
bgm CreditAttribution: bgm commentedsubscribe
(this is a major issue if managing multi-lingual CiviCRM sites in Aegir)
Comment #13
anarcat CreditAttribution: anarcat commentedInstead of using a tempfile, the output of mysqldump should be sent straight into sed and then redirected to the file. Pseudocode:
Also, instead of replacing the DEFINER line with emptiness, we should comment it out or delete it (//d).
Comment #14
Steven Jones CreditAttribution: Steven Jones commentedComment #15
Steven Jones CreditAttribution: Steven Jones commentedSo, I had a go at combining the sed commands from #9 and anarcat's all in a single line approach.
Patches attached.
Comment #16
attiks CreditAttribution: attiks commentedPatch in #15 is working for me (6.x-1.x)
Comment #17
anarcat CreditAttribution: anarcat commentedsteven, i'll let you do the honors of pushing your patch. :)
Comment #18
Steven Jones CreditAttribution: Steven Jones commentedAssigning to me then.
Comment #19
MrAdamJohn CreditAttribution: MrAdamJohn commentedpatch in #15 on 6 worked for me.
Comment #20
bgm CreditAttribution: bgm commented#15 works for me as well (tested on a site with CiviCRM). thanks!
Comment #21
bgm CreditAttribution: bgm commentedHmm, in fact, it seems that I am having issues on a server with MySQL 5.1. My database dump has the following:
I added a sed expression to remove that specific part, based on the patch from #15.
Comment #22
anarcat CreditAttribution: anarcat commentedComment #23
SocialNicheGuru CreditAttribution: SocialNicheGuru commented#15 worked for me too
Comment #24
Steven Jones CreditAttribution: Steven Jones commentedMaybe we need to research to see if we need to remove any other lines too.
Comment #25
anarcat CreditAttribution: anarcat commented@SocialNicheGuru but can you test the patch in #21?
Comment #26
bgm CreditAttribution: bgm commented@Steven Jones: CiviCRM uses MySQL InnoDB extensively (especially for multi-lingual, relies on Views/Triggers), so I think it makes a good test-case. I checked the resulting SQL and it is pretty clean.
Comment #27
jun CreditAttribution: jun commentedPatch at #21 worked for me. +1 for committing.
Comment #28
anarcat CreditAttribution: anarcat commentedthis looks like rtbc now
Comment #29
anarcat CreditAttribution: anarcat commentedfix committed to head and 1.x
Comment #31
anarcat CreditAttribution: anarcat commentedSorry to reopen this really old issue, but I need feedback from the people that actually use MySQL views (which is not often my case).
After reading on this issue after getting in a pretty good SNAFU on a CiviCRM site here, I have discovered that people only remove the DEFINER bit, not the ALGO parts. Doing this could simplify the pipeline. Take this for example:
https://gist.github.com/1228701
A single regex:
Why do we also do this?
Worst, why isn't the sed pipeline combined into one? Again, here's the current pipeline, whitespace added for clarity:
Doesn't that seem redundant to people here?
Thanks for the feedback.
PS: note that I have already removed the
\s*
statement in 2.x from the above because (1) it was not properly escaped and (2) it is a perlism, and won't work in sed...PPS: for reference, the upstream MySQL and MariaDB bugs: http://bugs.mysql.com/bug.php?id=24680 https://mariadb.atlassian.net/browse/MDEV-3836
Comment #32
Steven Jones CreditAttribution: Steven Jones commentedI think that the current 'multi-sed' approach was taken because that was the way that the command came about, i.e. built up over time and added too, not for any other reason really. I suspect that there's too much magic in that single command to understand fully, easily, so people only tinker with parts of it.
Comment #33
helmo CreditAttribution: helmo commentedThe patch from #21, committed in #29 caused a regression: #2098289: Backup task does not detect failed database dump
Is this still a problem? Please re-open with more information...
Comment #34
anarcat CreditAttribution: anarcat commentedwell the reason i marked this as needs work is because the pipeline seems sick in the head and should be simplified. i think this is still valid, unless i missed a commit.
Comment #35
ergonlogicComment #36
ergonlogicThis should be fixed by recent refactoring of this code. We now do the filtering line by line via proc_open() and preg_replace(), rather than piping to sed which was suppressing errors in mysqldumps. We also now have a hook to alter or add to the reflexes we run.
Comment #37
helmo CreditAttribution: helmo at Initfour websolutions commentedComment #38
omega8cc CreditAttribution: omega8cc commentedIn fact the code refactoring introduces regression which breaks things completely.
Comment #39
ergonlogicThe regex anchors were misplaced. Re-open this issue if this bug persists for you on commit 880a57e, or later.