mysql: can't set max_allowed_package to anything grater than 16MB
Posted
by sas
on Stack Overflow
See other posts from Stack Overflow
or by sas
Published on 2009-01-04T21:59:10Z
Indexed on
2010/04/20
9:53 UTC
Read the original article
Hit count: 257
I'm not sure if this is the right place to post these kind of questions, if it's not so, please (politely) let me know... :-)
I need to save files greater than 16MB on a mysql database from a php site...
I've already changed the c:\xampp\mysql\bin\my.cnf
and set max_allowed_packet to 16 MB, and everything worked fine
then I set it to 32 MB but there´s no way I can handle a file bigger than 16 MB
I get the following error:
'MySQL server has gone away'
(the same error I had when max_allowed_packet was set to 1MB)
there must be some other setting that doesn´t allow me to handle files bigger than 16MB
maybe the php client, I guess, but I don't know where to edit it
this is the code I'm running
when file.txt is smaller than 16.776.192 bytes long, it works fine, but
if file.txt has 16.777.216 bytes i get the aforementioned error
oh, and the field download.content is a longblob...
$file = 'file.txt';
$file_handle = fopen( $file, 'r' );
$content = fread( $file_handle, filesize( $file ) );
fclose( $file_handle );
db_execute( 'truncate table download', true );
$sql =
"insert into download(
code, title, name, description, original_name,
mime_type, size, content,
user_insert_id, date_insert, user_update_id, date_update )
values (
'new file', 'new file', 'sas.jpg', 'new file', '$file',
'mime', " . filesize( $file ) . ", '" . addslashes( $content ) . "',
0, " . db_char_to_sql( now_char(), 'datetime' ) . ", 0, " . db_char_to_sql( now_char(), 'datetime' ) . " )";
db_execute( $sql, true );
(the db_execute funcion just opens the connections and executes the sql stuff)
running on windows XP sp2
server version: 5.0.67-community
PHP Version 4.4.9
mysql client API version: 3.23.49
using: ApacheFriends XAMPP (Basispaket) version 1.6.8
that comes with
+ Apache 2.2.9
+ MySQL 5.0.67 (Community Server)
+ PHP 5.2.6 + PHP 4.4.9 + PEAR
+ phpMyAdmin 2.11.9.2
...
this is part of the content of
c:\xampp\mysql\bin\my.cnf
# The MySQL server [mysqld] port= 3306 socket= "C:/xampp/mysql/mysql.sock" basedir="C:/xampp/mysql" tmpdir="C:/xampp/tmp" datadir="C:/xampp/mysql/data" skip-locking key_buffer = 16M # max_allowed_packet = 1M max_allowed_packet = 32M table_cache = 128 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M
© Stack Overflow or respective owner