Phpmyadmin export VIEW without DATABASE_NAME or ALGORITHM

后端 未结 7 1896
忘了有多久
忘了有多久 2021-02-03 11:29

When exporting a sql dump with phpmyadmin it creates the VIEW table like this:

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER 
VIEW `         


        
7条回答
  •  囚心锁ツ
    2021-02-03 12:12

    When exporting a sql dump with phpmyadmin it creates the VIEW table like this:

    I've checked with mysqldump, which does precisely the same. Both mysqldump as PHPMyAdmin seem to execute SHOW CREATE, which results in having a security definer in the create statement. I don't see any way to "turn it off".

    Each time I have to manually edit the sql dump to remove the root user and database name.

    This is where I can help though. Manually editing an SQL file is hell and it's too error-prone. I've had these issues before where the exporting user didn't exist on the platform I wanted to import. The only thing I needed to edit was everything between CREATE and VIEW.

    Now, since you've tagged your question with php, I imagine you know how to use it from commandline. Here's a script that will replace all of the non-necessary values with an empty string:

    Maybe not a direct answer to your question, but it should prevent you from having to manually edit the dumps.

提交回复
热议问题