Skip to content

Instantly share code, notes, and snippets.

@Sjeanpierre
Created June 15, 2015 19:04
Show Gist options
  • Save Sjeanpierre/62efa0c2701aa4d55438 to your computer and use it in GitHub Desktop.
Save Sjeanpierre/62efa0c2701aa4d55438 to your computer and use it in GitHub Desktop.
Connect to database defined by rails databae.yml when on a server
#! /usr/bin/env bash
USERNAME=`cat config/database.yml | grep username | awk {'print$2'}`
PASSWORD=`cat config/database.yml | grep password | awk {'print$2'}`
HOST=`cat config/database.yml | grep host | awk {'print$2'}`
DATABASE=`cat config/database.yml | grep database | awk {'print$2'}`
mysql -h $HOST -u $USERNAME -D $DATABASE -p$PASSWORD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment