mysql导入视图错误ERROR 1449

MYSQL导入时,如果存在视图,可能导致导入不成功,错误提示: ERROR 1449(HY000) at line xxx: The user specified as a definer (‘xxx’@’xxx’) does not exist

解决办法1:

sed '/\/*!50013/d' backup.sql > backup_without_50013.sql

解决办法2:

$contents = file_get_contents('backups/backup.sql');
$contents = preg_replace('@/*!50013 DEFINER.*?*/@' , '' , $contents);
file_put_contents('backups/backup.sql' , $contents);

Import mysql dump files with view definer and sql security