MySQL upload problem

This is a discussion on MySQL upload problem within the PHP General forums, part of the PHP Programming Forums category; Hi gang: I know that this is not a php question, but all of you are so smart I thought ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-11-2007
tedd
 
Posts: n/a
Default MySQL upload problem

Hi gang:

I know that this is not a php question, but all of you are so smart I
thought would ask anyway.

I need to upload a 5 Meg sql file to a client's database. However,
his site's phpMyAdmin shows a maximum file size limit of 2 Meg.

Now, is this something that is controlled by his host, or is there a
way for me to get around it without requiring his host to do
something, or what? How can I do this?

Advice sought.

Cheers,

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
Reply With Quote
  #2 (permalink)  
Old 09-11-2007
Stut
 
Posts: n/a
Default Re: [PHP] MySQL upload problem

tedd wrote:
> I know that this is not a php question, but all of you are so smart I
> thought would ask anyway.
>
> I need to upload a 5 Meg sql file to a client's database. However, his
> site's phpMyAdmin shows a maximum file size limit of 2 Meg.
>
> Now, is this something that is controlled by his host, or is there a way
> for me to get around it without requiring his host to do something, or
> what? How can I do this?


Manually break the SQL file into several pieces. You may need to
duplicate some statements at the top and tail of the main file in each
part and also make sure that you duplicate any USE DATABASE statements
to ensure you're on the right DB.

You'll also need to make sure you execute them on the server in order.

-Stut

--
http://stut.net/
Reply With Quote
  #3 (permalink)  
Old 09-12-2007
tedd
 
Posts: n/a
Default Re: [PHP] MySQL upload problem

At 4:46 PM +0100 9/11/07, Stut wrote:
>tedd wrote:
>>I know that this is not a php question, but all of you are so smart
>>I thought would ask anyway.
>>
>>I need to upload a 5 Meg sql file to a client's database. However,
>>his site's phpMyAdmin shows a maximum file size limit of 2 Meg.
>>
>>Now, is this something that is controlled by his host, or is there
>>a way for me to get around it without requiring his host to do
>>something, or what? How can I do this?

>
>Manually break the SQL file into several pieces. You may need to
>duplicate some statements at the top and tail of the main file in
>each part and also make sure that you duplicate any USE DATABASE
>statements to ensure you're on the right DB.
>
>You'll also need to make sure you execute them on the server in order.
>
>-Stut


-Stut:

This is a relational dB and the several times that I have attempted
to load it in "in parts" has met with failure.

I was thinking that I could ftp the sql file to the clients server
and then run a php script on his server, something like:

$sql = "mysql -h$dbhost -u$dbuser -p$dbpass $dbname < $filename";
system($sql);

But, that didn't work -- however -- using mysqldump did download the
file. So, I'm close.

I know that safe_mode is ON, but I'm not sure if that's what's
causing the failure or something else.

There has to be a simple way to do this.

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
Reply With Quote
  #4 (permalink)  
Old 09-12-2007
Chris
 
Posts: n/a
Default Re: [PHP] MySQL upload problem

tedd wrote:
> At 4:46 PM +0100 9/11/07, Stut wrote:
>> tedd wrote:
>>> I know that this is not a php question, but all of you are so smart I
>>> thought would ask anyway.
>>>
>>> I need to upload a 5 Meg sql file to a client's database. However,
>>> his site's phpMyAdmin shows a maximum file size limit of 2 Meg.
>>>
>>> Now, is this something that is controlled by his host, or is there a
>>> way for me to get around it without requiring his host to do
>>> something, or what? How can I do this?

>>
>> Manually break the SQL file into several pieces. You may need to
>> duplicate some statements at the top and tail of the main file in each
>> part and also make sure that you duplicate any USE DATABASE statements
>> to ensure you're on the right DB.
>>
>> You'll also need to make sure you execute them on the server in order.
>>
>> -Stut

>
> -Stut:
>
> This is a relational dB and the several times that I have attempted to
> load it in "in parts" has met with failure.


Split the database up per table - I have a perl script if you want it.

Upload each table separately.

--
Postgresql & php tutorials
http://www.designmagick.com/
Reply With Quote
  #5 (permalink)  
Old 09-12-2007
brian
 
Posts: n/a
Default Re: [PHP] MySQL upload problem

tedd wrote:
> I was thinking that I could ftp the sql file to the clients server and
> then run a php script on his server, something like:
>
> $sql = "mysql -h$dbhost -u$dbuser -p$dbpass $dbname < $filename";
> system($sql);
>
> But, that didn't work -- however -- using mysqldump did download the
> file. So, I'm close.
>
> I know that safe_mode is ON, but I'm not sure if that's what's causing
> the failure or something else.
>


Just a thought: did you pass the full path for $filename?

Also, pass in a return var to read:

system($sql, $ret);

if ($ret === 0) { echo 'sucess'; }

Sorry, you'll have to hunt down the other return codes that MySQl might
send back.

If safe_mode is enabled, your command will be escaped with
escapeshellcmd() but that's about it.

If you can FTP it but can't get a shell is there any chance you could
convince an admin to run the script?

brian
Reply With Quote
  #6 (permalink)  
Old 09-12-2007
Chris
 
Posts: n/a
Default Re: [PHP] MySQL upload problem

tedd wrote:
> At 4:46 PM +0100 9/11/07, Stut wrote:
>> tedd wrote:
>>> I know that this is not a php question, but all of you are so smart I
>>> thought would ask anyway.
>>>
>>> I need to upload a 5 Meg sql file to a client's database. However,
>>> his site's phpMyAdmin shows a maximum file size limit of 2 Meg.
>>>
>>> Now, is this something that is controlled by his host, or is there a
>>> way for me to get around it without requiring his host to do
>>> something, or what? How can I do this?

>>
>> Manually break the SQL file into several pieces. You may need to
>> duplicate some statements at the top and tail of the main file in each
>> part and also make sure that you duplicate any USE DATABASE statements
>> to ensure you're on the right DB.
>>
>> You'll also need to make sure you execute them on the server in order.
>>
>> -Stut

>
> -Stut:
>
> This is a relational dB and the several times that I have attempted to
> load it in "in parts" has met with failure.
>
> I was thinking that I could ftp the sql file to the clients server and
> then run a php script on his server, something like:
>
> $sql = "mysql -h$dbhost -u$dbuser -p$dbpass $dbname < $filename";
> system($sql);
>
> But, that didn't work -- however -- using mysqldump did download the
> file. So, I'm close.


Actually reading the php site:

http://php.net/system

With safe mode enabled, the command string is escaped with escapeshellcmd().

Then http://www.php.net/manual/en/functio...eshellcmd.php:

Following characters are preceded by a backslash: #&;`|*?~<>^()[]{}$\,
\x0A and \xFF.

So your < is being replaced with \< which is why it wouldn't work.

--
Postgresql & php tutorials
http://www.designmagick.com/
Reply With Quote
  #7 (permalink)  
Old 09-12-2007
brian
 
Posts: n/a
Default Re: [PHP] MySQL upload problem

brian wrote:
> tedd wrote:
>
>> I was thinking that I could ftp the sql file to the clients server and
>> then run a php script on his server, something like:
>>
>> $sql = "mysql -h$dbhost -u$dbuser -p$dbpass $dbname < $filename";
>> system($sql);
>>
>> But, that didn't work -- however -- using mysqldump did download the
>> file. So, I'm close.
>>
>> I know that safe_mode is ON, but I'm not sure if that's what's causing
>> the failure or something else.
>>

>
> Just a thought: did you pass the full path for $filename?
>
> Also, pass in a return var to read:
>
> system($sql, $ret);
>
> if ($ret === 0) { echo 'sucess'; }
>
> Sorry, you'll have to hunt down the other return codes that MySQl might
> send back.
>
> If safe_mode is enabled, your command will be escaped with
> escapeshellcmd() but that's about it.
>
> If you can FTP it but can't get a shell is there any chance you could
> convince an admin to run the script?
>


Also, to be on the safe side, you might want to include
set_time_limit(0); in your script, also (if you can get system() to
work, that is).

brian
Reply With Quote
  #8 (permalink)  
Old 09-12-2007
brian
 
Posts: n/a
Default Re: [PHP] MySQL upload problem

Chris wrote:
> tedd wrote:
>>
>> I was thinking that I could ftp the sql file to the clients server and
>> then run a php script on his server, something like:
>>
>> $sql = "mysql -h$dbhost -u$dbuser -p$dbpass $dbname < $filename";
>> system($sql);
>>
>> But, that didn't work -- however -- using mysqldump did download the
>> file. So, I'm close.

>
>
> Actually reading the php site:
>
> http://php.net/system
>
> With safe mode enabled, the command string is escaped with
> escapeshellcmd().
>
> Then http://www.php.net/manual/en/functio...eshellcmd.php:
>
> Following characters are preceded by a backslash: #&;`|*?~<>^()[]{}$\,
> \x0A and \xFF.
>
> So your < is being replaced with \< which is why it wouldn't work.
>


Right. You could try mysqlimport to get around using the < instead.
Strip out all but the ddl statements (CREATE TABLE and friends) and
place them into separate files for each table. That is, name each file
for the table its data corresponds to. Upload the ddl stuff with
phpMyAdmin, then import the data with mysqlimport through your script.

However, i think you might need FILE privilege.

Instead of putzing around with your existing dump file to copy
everything out, you could import everything to a local database (if you
don't have it already) and dump out each table to a separate file.

brian
Reply With Quote
  #9 (permalink)  
Old 09-13-2007
tedd
 
Posts: n/a
Default Re: [PHP] MySQL upload problem (solved)

tedd wrote:
>I was thinking that I could ftp the sql file to the clients server
>and then run a php script on his server, something like:
>
>$sql = "mysql -h$dbhost -u$dbuser -p$dbpass $dbname < $filename";
>system($sql);
>
>But, that didn't work -- however -- using mysqldump did download the
>file. So, I'm close.
>
>I know that safe_mode is ON, but I'm not sure if that's what's
>causing the failure or something else.



We got the host to install a newer version of phpMyAdmin. It worked
by breaking the dB into tables and then doing the transfer.

Thanks to all.

Cheers,

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
Reply With Quote
  #10 (permalink)  
Old 09-14-2007
Teo Mattiozzi
 
Posts: n/a
Default php-general-unsubscribe@lists.php.net

php-general-unsubscribe@lists.php.net



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:09 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0