Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing sql statements to os

Status
Not open for further replies.

NearAway

Technical User
Feb 6, 2003
9
CA
hi all,

just wondering, is there a way to run sql statements as a single shell command?

What I mean is that I don't want to have to log in the mysql.exe util. For example, I can log into mysql and run a sql statement like this:

mysql -u root -p
...

mysql> use MyDBName
mysql> insert into table1 blah blah..


However, I would prefer if I could just skip the whole logging ing part entirely.


According to the mysql documentation, this should work:

C:\mysql\bin\>mysql --user=root --password=rootpass DBName insert into table1 blah blah..

but that doesn't work.

Is what I'm trying to achieve possible? Seems to me like it should be, but the mysql documentation isn't very clear on how to do this. thanks

Rick
 
Put your SQL statements in a text file and redirect them to MySQL:

mysql --user=root --password=rootpass DBName < yoursqlfile.sql
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top