Thursday, January 31, 2013

How to Run the MySQL Query Through the Command Prompt?

1 comments 1/31/2013
Sign up to receive our site updates!
Check out useful posts regarding MySQL optimization
  • How to Backup/Restore/Crate/Drop the MYSQL Data Base through the Command Prompt?
  • how to optimize the Stored Procedure?
  • how to avoid the Cursors inside the Stored procedure?

  • To run the query directly from the command Prompt:
    mysql –u[Username] –p[Password] -e "select * from tbl_emp where emp_id=2" [DataBaseName]
    -e’ :- execute the query
    Even we can store the result to file
    mysql –u[Username] –p[Password] -e "select * from tbl_emp where emp_id=2" [DataBaseName] > D:\test.log
    To run the Sql Queries file through the command prompt:
    The sql file can contain any kind of quires like select/update/sp call etc…
    mysql –u[Username] –p[Password] –h[IP Address] [DataBaseName] < "D:\Test.sql"
    To store the output to log/text file:
    mysql –u[Username] –p[Password] –h[IP Address] [DataBaseName] < "D:\Test.sql" > "D:\Test.log"
    Your Ad Here

    1 comments:

    devtools korzh on October 20, 2013 at 5:50 PM said... [Reply]

    Thanks for the advice!

    Respects for your's Questions & Opinions

  • Friends
  •  

    Recent Posts

    Copyright 2008 All Rights Reserved Tech Tasks Template by Rajesh Kumar Chekuri