Unix Technical Forum

RE: What's the PHP equivallent of "mysql mydb < somefile.sql"

This is a discussion on RE: What's the PHP equivallent of "mysql mydb < somefile.sql" within the MySQL General forum forums, part of the MySQL category; --> I don't know if it will work - but have you tried using SOURCE in the mysql query? -----Original ...


Go Back   Unix Technical Forum > Database Server Software > MySQL > MySQL General forum

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 09:30 PM
Ligaya A. Turmelle
 
Posts: n/a
Default RE: What's the PHP equivallent of "mysql mydb < somefile.sql"

I don't know if it will work - but have you tried using SOURCE in the mysql query?

-----Original Message-----
From: Daevid Vincent [mailto:daevid@daevid.com]
Sent: Tuesday, October 10, 2006 11:01 AM
To: mysql@lists.mysql.com
Subject: What's the PHP equivallent of "mysql mydb < somefile.sql"

Currently I run an 'updater' script to run through a directory of .sql files using something like this in PHP:

$COMMAND = "mysql ".$OPTION['db_prefix'].$db." < ".$mydir.$filename;
system($COMMAND, $ret);

What would be the equivallent way to to this in a PHP mysql_query(""); way?

I see "LOAD", but that only works for data it seems.
http://dev.mysql.com/doc/refman/5.0/en/load-data.html

These scripts I use have ALTER statements and CREATE and all other types of SQL in them and almost no data actually.

mySQL 5.0.15


ÐÆ5ÏÐ


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=lig@maolek.com


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 09:30 PM
Daevid Vincent
 
Posts: n/a
Default RE: What's the PHP equivallent of "mysql mydb < somefile.sql"

Could you be more specific? What is "SOURCE"? Where do I use that? I tried
to search, but I find a lot of hits related to source code.

> -----Original Message-----
> From: Ligaya A. Turmelle [mailto:lturmelle@guamcell.com]
> Sent: Monday, October 09, 2006 6:57 PM
> To: Daevid Vincent; mysql@lists.mysql.com
> Subject: RE: What's the PHP equivallent of "mysql mydb < somefile.sql"
>
> I don't know if it will work - but have you tried using
> SOURCE in the mysql query?
>
> -----Original Message-----
> From: Daevid Vincent [mailto:daevid@daevid.com]
> Sent: Tuesday, October 10, 2006 11:01 AM
> To: mysql@lists.mysql.com
> Subject: What's the PHP equivallent of "mysql mydb < somefile.sql"
>
> Currently I run an 'updater' script to run through a
> directory of .sql files using something like this in PHP:
>
> $COMMAND = "mysql ".$OPTION['db_prefix'].$db." <
> ".$mydir.$filename;
> system($COMMAND, $ret);
>
> What would be the equivallent way to to this in a PHP
> mysql_query(""); way?
>
> I see "LOAD", but that only works for data it seems.
> http://dev.mysql.com/doc/refman/5.0/en/load-data.html
>
> These scripts I use have ALTER statements and CREATE and all
> other types of SQL in them and almost no data actually.
>
> mySQL 5.0.15
>
>
> ÐÆ5ÏÐ
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=lig@maolek.com
>
>
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 09:30 PM
Chris W
 
Posts: n/a
Default Re: What's the PHP equivallent of "mysql mydb < somefile.sql"

Read the section on the manual on the Client and Utility programs,
specifically mysql. The syntax is essentially the same as you have in
your code .... something like this from the command line....

mysql -u dbUser -pMyPassword dbName <SomeFileWithLotsOfSQLCommands.sql

Note there is no space between the '-p' and the password.

Daevid Vincent wrote:
> Could you be more specific? What is "SOURCE"? Where do I use that? I tried
> to search, but I find a lot of hits related to source code.
>
>
>> -----Original Message-----
>> From: Ligaya A. Turmelle [mailto:lturmelle@guamcell.com]
>> Sent: Monday, October 09, 2006 6:57 PM
>> To: Daevid Vincent; mysql@lists.mysql.com
>> Subject: RE: What's the PHP equivallent of "mysql mydb < somefile.sql"
>>
>> I don't know if it will work - but have you tried using
>> SOURCE in the mysql query?
>>
>> -----Original Message-----
>> From: Daevid Vincent [mailto:daevid@daevid.com]
>> Sent: Tuesday, October 10, 2006 11:01 AM
>> To: mysql@lists.mysql.com
>> Subject: What's the PHP equivallent of "mysql mydb < somefile.sql"
>>
>> Currently I run an 'updater' script to run through a
>> directory of .sql files using something like this in PHP:
>>
>> $COMMAND = "mysql ".$OPTION['db_prefix'].$db." <
>> ".$mydir.$filename;
>> system($COMMAND, $ret);
>>
>> What would be the equivallent way to to this in a PHP
>> mysql_query(""); way?
>>
>> I see "LOAD", but that only works for data it seems.
>> http://dev.mysql.com/doc/refman/5.0/en/load-data.html
>>
>> These scripts I use have ALTER statements and CREATE and all
>> other types of SQL in them and almost no data actually.
>>
>> mySQL 5.0.15
>>
>>
>> ÐÆ5ÏÐ
>>
>>
>> --
>> MySQL General Mailing List
>> For list archives: http://lists.mysql.com/mysql
>> To unsubscribe: http://lists.mysql.com/mysql?unsub=lig@maolek.com
>>
>>
>>
>>

>
>
>



--
Chris W
KE5GIX

"Protect your digital freedom and privacy, eliminate DRM,
learn more at http://www.defectivebydesign.org/what_is_drm"

Gift Giving Made Easy
Get the gifts you want &
give the gifts they want
One stop wish list for any gift,
from anywhere, for any occasion!
http://thewishzone.com

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:25 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com