{"id":683,"date":"2014-03-10T21:00:19","date_gmt":"2014-03-10T21:00:19","guid":{"rendered":"http:\/\/shivdev.com\/blog\/?p=683"},"modified":"2014-03-10T21:07:08","modified_gmt":"2014-03-10T21:07:08","slug":"execute-mysql-queries-from-command-line","status":"publish","type":"post","link":"http:\/\/shivdev.com\/blog\/2014\/03\/10\/execute-mysql-queries-from-command-line\/","title":{"rendered":"Execute MySQL queries from Command Line"},"content":{"rendered":"<p>If say, you want to capture the results of MySQL query into a file, you might want to run use the command line option <strong>(-e)<\/strong> to execute the SQL query.<\/p>\n<p>You can follow the syntax:<br \/>\n mysql <strong>-u<\/strong><em>user<\/em> <strong>-p<\/strong><em>password<\/em> <em>database <\/em><strong>-e<\/strong> &#8216;<em>query_to_execute<\/em>&#8216;<\/p>\n<blockquote><p>\n# Show on stdout<br \/>\n$ mysql <strong>-u<\/strong>user <strong>-p<\/strong>password database <strong>-e &#8216;show tables&#8217;<\/strong><\/p>\n<p># Redirect to a file<br \/>\n$ mysql <strong>-u<\/strong>user <strong>-p<\/strong>password database <strong>-e &#8216;show tables&#8217;<\/strong> > tables.txt\n<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8216;query_to_execute&#8216; # Show on stdout $ mysql -uuser -ppassword database -e &#8216;show tables&#8217; # Redirect [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/683"}],"collection":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/comments?post=683"}],"version-history":[{"count":7,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/683\/revisions"}],"predecessor-version":[{"id":690,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/683\/revisions\/690"}],"wp:attachment":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/media?parent=683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/categories?post=683"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/tags?post=683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}