Execute MySQL queries from Command Line
Writing by shivdev on Monday, 10 of March , 2014 at 9:00 pm
If say, you want to capture the results of MySQL query into a file, you might want to run use the command line option (-e) to execute the SQL query.
You can follow the syntax:
mysql -uuser -ppassword database -e ‘query_to_execute‘
# Show on stdout
$ mysql -uuser -ppassword database -e ‘show tables’# Redirect to a file
$ mysql -uuser -ppassword database -e ‘show tables’ > tables.txt
Leave a comment
Category: SQL DB
- Add this post to
- Del.icio.us -
- Digg -
- -
- Tweet -
-
-
No comments yet.
You must be logged in to post a comment.