Skip to content

Instantly share code, notes, and snippets.

@queso
Created December 2, 2008 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save queso/31161 to your computer and use it in GitHub Desktop.
Save queso/31161 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'mysql'
require 'highline/import'
database = ARGV[0] + "_production"
username = ARGV[0] + "_dba"
password = ask("Enter the password for the new database: ") { |q| q.echo = "*" }
root_password = ask("Enter your root database password: ") { |q| q.echo = "*" }
db = Mysql.real_connect("localhost", "root", root_password)
db.query("CREATE DATABASE #{database}")
db.query("GRANT ALL PRIVILEGES ON #{database}.* TO '#{username}'@'%' IDENTIFIED BY '#{password}'")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment