troubleshooting Question

Using shell_exec() or exec() to run an external .sql file from PHP...

Avatar of JMoridin
JMoridin asked on
Web Languages and StandardsPHP
7 Comments1 Solution1472 ViewsLast Modified:
Greetings:


I have 3 .sql files I am attempting to run via .php for a database administration panel of sorts.
- create_database.sql //to create the database, tables, and attributes
- insert_company_values.sql //inserts populate one portion of the database
- insert_student_values.sql //inserts to popluate another portion of the database

I have tried several operators in PHPs, and most any syntax I can think of, and made SOME headway with the following:


$exec = shell_exec("C:\\mysql\\bin\\mysql --username=user --password=pass < C:\\Inetpub\\wwwroot\\database\\create_database.sql") or die("did not work");


This "appears" to work, as the function does not die or throw an error, but when I go back into mysql, the database has not been created.

If I echo the $exec, the output is what I noticed at the top of winmysqladmin and her is a basic excerpt (it is quite long):

Ver 11.18 Distrib 3.23.54, for Win95/Win98 (i32) Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL license Usage: C:\mysql\bin\mysql [OPTIONS] [database] -?, --help Display this help and exit. -A, --no-auto-rehash  ......  select_limit current value: 1000 max_join_size current value: 1000000

If any more information is needed, but these are the current results.

Note: Safe mode is NOT enabled for PHP.

Thanks kindly for your time and attention.


JMoridin.
ASKER CERTIFIED SOLUTION
Giovanni G
CTO

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros