Skip to content

Instantly share code, notes, and snippets.

@alexrinass
Created August 16, 2011 14:45
Show Gist options
  • Save alexrinass/1149248 to your computer and use it in GitHub Desktop.
Save alexrinass/1149248 to your computer and use it in GitHub Desktop.
Create new MySQL database
#!/bin/sh
DB="$1"
if [ -z "$DB" ]; then
echo "Usage: addmysqldb DB"
exit 0
fi
RESULT=$(echo "CREATE DATABASE \`$DB\` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;" |mysql5 mysql 2>&1)
if [ $? > 0 ]; then
echo "$RESULT"
exit 1
fi
echo "Created database '$DB' with UTF-8 character set."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment