mystix
1/2/2013 - 11:21 AM

Remove DEFINER statements from MySQL db dump

Remove DEFINER statements from MySQL db dump

#!/bin/bash
 
if [[ $# -ne 1 ]]; then
  echo "Usage: $0 <mysql db dump>"
  exit 1
elif [[ ! -f $1 ]]; then
  echo "File not found: $1"
  exit 1
fi
 
# remove MySQL DEFINER statements from mysql db dump
perl -p -i -e "s/DEFINER=\`\w.*\`@\`localhost\`//g" $1