-
-
Save andhapp/901355 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "creates database & database user" | |
task :create_database do | |
set :root_password, Capistrano::CLI.password_prompt("MySQL root password: ") | |
set :db_user, Capistrano::CLI.ui.ask("Application database user: ") | |
set :db_pass, Capistrano::CLI.password_prompt("Password: ") | |
set :db_name, Capistrano::CLI.ui.ask("Database name: ") | |
run "mysql --user=root --password=#{root_password} -e \"CREATE DATABASE IF NOT EXISTS #{db_name}\"" | |
run "mysql --user=root --password=#{root_password} -e \"GRANT ALL PRIVILEGES ON #{db_name}.* TO '#{db_user}'@'localhost' IDENTIFIED BY '#{db_pass}' WITH GRANT OPTION\"" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment