Created
July 3, 2015 14:13
-
-
Save kissarat/bbf33d10f9d7a3bc1adb to your computer and use it in GitHub Desktop.
Use it after export with mysqldump to remove SECURITY DEFINER(s)
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
<?php | |
$file = file_get_contents($argv[1]); | |
$position = strpos($file, 'Final view structure for view'); | |
if (false !== $position) { | |
echo substr($file, 0, $position); | |
} | |
else { | |
die('not found'); | |
} | |
# removes from end of file something like this | |
/* | |
-- | |
-- Final view structure for view `matrix` | |
-- | |
*/ | |
/*!50001 DROP VIEW IF EXISTS `matrix`*/; | |
/*!50001 SET @saved_cs_client = @@character_set_client */; | |
/*!50001 SET @saved_cs_results = @@character_set_results */; | |
/*!50001 SET @saved_col_connection = @@collation_connection */; | |
/*!50001 SET character_set_client = utf8mb4 */; | |
/*!50001 SET character_set_results = utf8mb4 */; | |
/*!50001 SET collation_connection = utf8mb4_general_ci */; | |
/*!50001 CREATE ALGORITHM=UNDEFINED */ | |
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ | |
/*!50001 VIEW `matrix` AS select `n`.`id` AS `id`,`n`.`type_id` AS `type_id`,`n`.`user_name` AS `user_name`,count(0) AS `count`,`n`.`reinvest_from` AS `reinvest_from` from (`node` `n` join `type` `t` on((`n`.`type_id` = `t`.`id`))) group by `n`.`reinvest_from`,`n`.`time`,`n`.`user_name`,`n`.`type_id` order by `n`.`time` */; | |
/*!50001 SET character_set_client = @saved_cs_client */; | |
/*!50001 SET character_set_results = @saved_cs_results */; | |
/*!50001 SET collation_connection = @saved_col_connection */; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment