Skip to content

Instantly share code, notes, and snippets.

@decioferreira
Created November 14, 2011 16:32
Show Gist options
  • Save decioferreira/1364366 to your computer and use it in GitHub Desktop.
Save decioferreira/1364366 to your computer and use it in GitHub Desktop.
Shell script and MySQL
#!/bin/bash
# MySQL connection
user_name="your_user_name"
db_name="your_db_name"
# Return the result of the query to a variable
result=$(mysql -u $user_name $db_name -sN -e "SELECT 1")
# print message on screen
echo "The result was $result!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment