Skip to content

Instantly share code, notes, and snippets.

@quickshiftin
Last active August 29, 2015 13:56
Show Gist options
  • Save quickshiftin/8942140 to your computer and use it in GitHub Desktop.
Save quickshiftin/8942140 to your computer and use it in GitHub Desktop.
mysqldbs - Show all mysql databases for a given host (defaults to localhost) a given user can view with a simple Bash alias.
alias mysqldbs='_() { local h=""; if [ ! -z "$2" ]; then h="-h$2"; fi; echo "show databases;" | mysql -u "$1" "$h" -p; }; _'
@quickshiftin
Copy link
Author

To use this simply type

mysqldbs root

for example to connect as root. You will then be prompted for a password, and after typing the password and hitting enter, you will get a listing of the databases.

You can specify a host other than localhost by providing a second argument

mysqldbs root mysql.example.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment