When exporting an sql dump with phpmyadmin, it creates a VIEW table as follows:
I checked with mysqldump
, which does the same thing. Both mysqldumps like PHPMyAdmin seem to perform SHOW CREATE, which leads to the presence of a security qualifier in the create statement. I see no way to "disable it."
Every time I have to manually edit the sql dump to remove the root username and database.
Here is where I can help. Manually editing the SQL file is hell and it is too error prone. I had these problems before the export user did not exist on the platform I wanted to import. The only thing I needed to edit was everything between CREATE and VIEW.
Now, since you tagged your question with php
, I think you know how to use it from the command line. Here is a script that will replace all unnecessary values ​​with an empty string:
<?php $string = 'CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `database`.`table` AS'; $string = preg_replace( '/CREATE .*(TABLE|VIEW) `[^`]+`\.(`[^`]+`)/s', 'CREATE $1 $2', $string ); var_dump( $string );
It may not be a direct answer to your question, but it should prevent you from manually editing dumps.
source share