Mysql: cannot set max_allowed_package to anything greater than 16MB

I am not sure if this is the right place to post such questions, if it is not, please (politely) let me know ... :-)

I need to save files larger than 16 MB in mysql database from php site ...

I already changed c: \ xampp \ mysql \ bin \ my.cnf

and set max_allowed_packet to 16 MB and everything works fine

then I set it to 32 MB, but I can not process a file larger than 16 MB

I get the following error:

"MySQL server is gone"

(same error as when max_allowed_packet was set to 1 MB)

there should be another parameter that does not allow me to process files larger than 16 MB

maybe php client i think but i dont know where to edit it

this is the code that I run

file.txt 16.776.192 , ,

file.txt 16.777.216 ,

oh, download.content - 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 );

( db_execute sql)

Windows XP sp2 : 5.0.67- PHP 4.4.9 API mysql: 3.23.49

: ApacheFriends XAMPP (Basispaket) 1.6.8 + Apache 2.2.9 + MySQL 5.0.67 (Community Server) + PHP 5.2.6 + PHP 4.4.9 + PEAR + phpMyAdmin 2.11.9.2 ...

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
+3
4

: .

mysql php () mysql, , , , ; , , . php mysql, .

, - , ( ) . ( , v3- v4), , .

phpinfo()

" Client API" mysql, .

-

, , "max_allowed_packet", . mysql,

mysql --max_allowed_packet 

set-variable   = max-allowed-packet=64M

[] my.cnf

, php my.cnf . php:

ext/mysql/libmysql/net.c:ulong max_allowed_packet=16*1024*1024L;

php- , , , , - -.

+3

PHP MySQL.

, . INSERT , , CONCAT.

, .

, . .

+1

max_allowed_packet . / . .

+1

The php.ini file also has a maximum upload file size. It is not directly related to MySQL, but if you use php to send data, this may be your problem.

; Maximum allowed size for uploaded files.
upload_max_filesize = 16M

; Maximum size of POST data that PHP will accept.
post_max_size = 16M
-one
source

All Articles