Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 176
  • Last Modified:

Executing a .sql file with CMD

Hi Experts,

I'm running MySQL on Win7, and I cannot remember, how can I execute myscript.sql from cmd?

Thank you
0
APD_Toronto
Asked:
APD_Toronto
  • 2
1 Solution
 
Seth SimmonsSr. Systems AdministratorCommented:
mysql < myscript.sql

of course, add other parameters in the beginning if you need to supply username/password, etc.
0
 
Mohammed KhawajaCommented:
Below is the syntax to use:

mysql --host=servernane --user=username --password=password database_name < pathTofilename.sql
i.e. mysql -host=jupiter.localdomain.local -user=john.doe -password=IdontKnow salesDB < myscript.sql
0
 
APD_TorontoAuthor Commented:
You can access remote machines too?
0
 
Seth SimmonsSr. Systems AdministratorCommented:
yes assuming the user account is granted access from a specific machine or % for any machine; used with grant statement
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now