Skip to content

Instantly share code, notes, and snippets.

@lavoiesl
Last active December 21, 2015 16:36
Show Gist options
  • Save lavoiesl/2626426 to your computer and use it in GitHub Desktop.
Save lavoiesl/2626426 to your computer and use it in GitHub Desktop.
Use credentials in /etc/mysql/debian.cnf to export MySQL database
#!/bin/bash
# Use credentials in /etc/mysql/debian.cnf to export MySQL database
database="$1"
shift
options="$@"
if [[ -z "$database" ]]; then
echo "Usage: $0 database [options]" >&2
exit 2
fi
sudo mysqldump \
--defaults-file=/etc/mysql/debian.cnf \
--add-drop-table \
--add-locks \
--comments \
--create-options \
--disable-keys \
--dump-date \
--extended-insert \
--no-create-db \
--lock-tables \
--set-charset \
--quick \
--routines \
--events \
--triggers \
$options \
$database
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment