SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2003
    Location
    l'Europe
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysql max_allowed_packet

    hi,

    I want to store some pdf files in a mysql-table (medium-blob sized).
    Let's say, the maximum file size is 5M.
    I've used Kevin Yank's script in chapter 11 to upload those files into the table.
    Like he noted in his book, there will be a problem on files larger than 1M.
    Indeed, I'm getting the error "Database error storing file: MySQL server has gone away"...
    I've searched www.mysql.com on the packet-too-large item and they suggested changing the value for max_allowed_packed.
    So I added to my.ini the line 'set-variable=max_allowed_packet=16M', I restarted my computer, but when I look into WinMySQLAdmin, the value of the variable isn't changed (still 1048576).
    What am I doing wrong?

    Thank you for any suggestions!

    Sincerly,
    Ann

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2003
    Location
    l'Europe
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, I've made following mistake:
    I put the line 'set-variable=max_allowed_packet=16M' at the bottom of the file, but that is in another section so I moved the line to the [mysqld] section.

    I can upload files larger than 1M and view them on my PC (server), but when I want to view the file on another pc, I get a blank screen...

    Ann

  3. #3
    SitePoint Zealot
    Join Date
    Aug 2002
    Posts
    142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this may not address directly what you need, but when I needed to put MP3s "into" a dbase, I found it better to list the filename and URL of the file in SQL and the actual data on the server in a folder, not actually in the dbase.

    you may want to consider this before spending too much time down the path you're on.

  4. #4
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Bear in mind also that an online mySQL database server may not let you change the max_allowed_packet setting.

    The way around this (other than as hakalugi suggests) is to have 2 tables ... 1 to store the file details etc. from which you retrieve a fileID value; and another table to hold your actual filedata - what you do here is to split the filedata into CHUNKS (each less than 1MB) and store each chunk in the 2nd table with a foreign-key relationship to the 1st table based on the fileID.

    When you retrieve the file from the database you merely get each CHUNK from the 2nd table and join them back together.

    It sounds complicated but it's not really.
    Ian Anderson
    www.siteguru.co.uk


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •