LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Escaping host limits in PHP (https://www.linuxquestions.org/questions/programming-9/escaping-host-limits-in-php-232627/)

hw-tph 09-19-2004 04:12 PM

Escaping host limits in PHP
 
I have bought a new domain and I am moving a board I run to the new host. The new host has a PHP memory allocation limit (memory_limit in php.ini) of 8M and it's giving me headaches. The post_max_size is also 8M. I have no shell access (FTP + phpMyAdmin only, except for http obviously).

I need to recover the database from the old host and it's about 14MB. Uploading this to phpMyAdmin is impossible because of the max_post_size, so I thought I could write a little script to simply use the MySQL dump (14MB on file) as a query. Simple enough, yes. But no, I get slammed by the memory_limit when I read the file, so no go there either.

This is an *extremely* cheap host and I guess I get what I pay for. Any ideas how I could solve this?


Håkan

Cedrik 09-19-2004 05:20 PM

try to upload your dumps with ftp and then load them in your new mysql server with a php script

hw-tph 09-20-2004 04:24 PM

I already tried this and it fails with the memory_limit problem:

Quote:

(...)so I thought I could write a little script to simply use the MySQL dump (14MB on file) as a query. Simple enough, yes. But no, I get slammed by the memory_limit when I read the file, so no go there either.

Håkan

Cedrik 09-21-2004 02:43 PM

You can't open the file with fopen() ?

hw-tph 09-21-2004 03:27 PM

No, since the file is larger (14MB) than memory_limit (8MB) the script gets killed for violating the memory limit when I try to read it.

I managed to solve the problem last night after some extensive social engineering (read: kissing ass to an admin) to get a user@"%" entry in MySQL so I could use my local MySQL client to manage the remote server (using source to simply read the dump).


Håkan

Cedrik 09-21-2004 04:09 PM

I didn't know that opening a 14 MB file will use 14 MB of memory ;)

hw-tph 09-21-2004 05:18 PM

Nope, but reading it into a variable sure will.

Do you have a suggestion on how to parse and execute an SQL dump and get the whole friggen lot into MySQL without actually reading the entire file at a time? I assume one could parse the file and grab the separate CREATE TABLE and INSERT statements one by one...but in a simple (as in quick and dirty and not spending an entire night) way?


Håkan

Cedrik 09-22-2004 03:46 AM

Generally a mysqldump is a list of mysql insert commands, one by line
PHP Code:

$mysql_id mysql_connect(...);
mysql_select_db(...);

$filename "/path/to/dump";

$fp fopen($filename"r");
if(!
$fp) { die ("can't open $filename to read"); }

while(!
feof($fp)) {
    
$sql fgets($fp2048);
    
mysql_query($sql$mysql_id);
}

fclose($fp); 



All times are GMT -5. The time now is 01:36 AM.