Executing SQL queries from the DOS prompt

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Sniper007
Forum Newbie
Posts: 17
Joined: Tue May 11, 2004 8:43 pm

Executing SQL queries from the DOS prompt

Post by Sniper007 »

Please, be gentle on me. I'm spoiled by phpMyAdmin. I've never had to run a command from the DOS prompt before... I am wondering how / if there is a way to run SQL commands and queries from the DOS prompt in WinXP. Specifically, a LOAD DATA INFILE command. What exactly is the syntax, for a command like that at the command prompt? I know it can't just be, "LOAD DATA INFILE... " That would never work... Is there some SQL.exe or something?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

there is a mysqlclient (called mysql.exe in the mysql/bin directory) which you can use for that.

It might be usefull to add that directory to your path (here you can see how to do that http://home.mysth.be/~timvw/articles/in ... 2sdk-winxp, it's similar for mysql)

mysql -u username -p < statements.sql is magic :)



[/url]
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post by lostboy »

actually it is about that simple (see here)..All you need to so is start the console on mysql

nvaigate to the mysql\bin dir and type mysqld then follow th example in the manual
Sniper007
Forum Newbie
Posts: 17
Joined: Tue May 11, 2004 8:43 pm

Alternate Solution

Post by Sniper007 »

Thanks, but I think I'm going to execute lines off of php.exe using CLI... Then just use whatever .php files I want that contain the SQL commands.

Code: Select all

C:\swamp\php\cli\php.exe -f C:\swamp\www\myphp.php
Post Reply