Phpmyadmin export VIEW without DATABASE_NAME or ALGORITHM

后端 未结 7 1906
忘了有多久
忘了有多久 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:17

    Maybe I'm not understanding... but this has always worked for me. There are no references to the database name and all definers get wiped out so it's super-easy to restore from the file it generates:

    mysqldump -uUSERNAME -pPASSWORD database |  sed -e 's/DEFINER=[^*]*\*/\*/' > backup.sql
    

    To restore:

    mysql -uUSERNAME -pPASSWORD database < backup.sql
    

    As long as the database you're restoring to exists (empty or not), works like a charm.

提交回复
热议问题