Skip to content

Instantly share code, notes, and snippets.

@xero
Created January 17, 2013 20:05
Show Gist options
  • Save xero/4559231 to your computer and use it in GitHub Desktop.
Save xero/4559231 to your computer and use it in GitHub Desktop.
this shell script will take an .sql backup file and install it to a given database. it will prompt you for username, password, database, and sql file. i set my default file location to ~/Downloads/ because that's where i always have my backups. edit as necessary.
#!/bin/sh
echo -e "\e[01;33m[username]\e[00m"
read user
echo -e "\e[01;33m[password]\e[00m"
read pass
echo -e "\e[01;33m[database]\e[00m"
read db
echo -e "\e[01;33m[sql file]\e[00m"
read file
mysql> mysql -u $user -p $pass $db < ~/Downloads/$file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment