MySQL Server Has Gone Away or "Elvis Has Left the Building!"

I've got sql file I'm trying to import into my database using phpMyAdmin. Cake and Ice Cream, right? The sql file is a little over 6MB. Every time I attempt to import it, I get a message that says "MySQL server has gone away.

I've been able to access my.ini and I changed the read_buffer_size to 8 M and the key_buffer_size to 32M. I chose these settings based on what I able to learn via google. Still getting the same error which tells me that I'm missing something.

What do I need to change?

brucegustPHP DeveloperAsked:
Who is Participating?
Phil PhillipsConnect With a Mentor Director of DevOps & Quality AssuranceCommented:
Yes, looks like you're either editing the wrong my.ini file, or there's an override somewhere.  Also, make sure you are restarting MySQL after making changes ;).

Just to get things working, you can try executing these commands in MySQL:

SET GLOBAL max_allowed_packet=134217728;
SET GLOBAL wait_timeout=600;

Open in new window

That should at least force those settings, and you can try the import.  If that works, then you can at least continue on and take your time in figuring out which conf file to edit :).
Phil PhillipsDirector of DevOps & Quality AssuranceCommented:
Try changing wait_timeout and max_allowed_packet.  For testing, you can go big with:

wait_timeout = 600
max_allowed_packet = 128M

Open in new window

brucegustPHP DeveloperAuthor Commented:
Phil! Thanks for getting back with me!

It didn't work, but let me ask you this:

First of all, I'm using my.ini as opposed to my.cnf. From what I can gather, it's the same thing, it just depends on your operating system, correct?

Second, on my my.ini, I see a bunch of lines prefaced with "Uncomment the following if you are using InnoDB tables:

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = C:\mysql\data/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = C:\mysql\data/
#innodb_log_arch_dir = C:\mysql\data/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 600

When I look at myPhpAdmin at I'm perusing the "type" of tables that I have, I see "InnoDB." Do I need to uncomment those lines?

BTW: I appreciate your help. I'm trying to get this app live today and it's nothing more than making a couple of tweaks and uploading some tables to a database. I've never encountered this error and it's killin' me!

What do you think?
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Phil PhillipsDirector of DevOps & Quality AssuranceCommented:
On Windows, my.ini will work.  You can also run 'SHOW VARIABLES' as a query just to make sure that the options are being set.

Yes, you can uncomment those if you are using InnoDB, and go ahead and tweak the memory settings depending on the size of your RAM (refer to the comments within the config file).  Though, I'm not sure that will fix the problem.  For me, it's only really been the network settings that caused that particular issue.
brucegustPHP DeveloperAuthor Commented:
OK, Phil! Check this out.

I had an epiphane. I took the same sql file and attempted it upload to another database using phpmyAdmin on another computer. It took a while, but it worked.

Copied the my.ini file from that computer and pasted it into the configuration I've got on this box.

Ran it and got the same message: "MySQL server has gone away."

You mentioned "network settings." Mind you this is my localhost. Can you think of anything else?
brucegustPHP DeveloperAuthor Commented:
Also, if I uncomment the lines pertaining to innodb..., nothing works. phpmyAdmin, anything related to the database just flat out quits. Add the "#" back in, gold. But I can't change those settings and have the thing work.
Phil PhillipsDirector of DevOps & Quality AssuranceCommented:
The network settings I was referring to were 'wait_timeout' and 'max_allowed_packet'.  Check to see through the 'SHOW VARIABLES' query that the settings are actually applied.

An ugly hack would be to try to split up the dump into smaller files (but you shouldn't have to do that...)
brucegustPHP DeveloperAuthor Commented:
wait_timeout is set to 28800 and max_allowed_packet is 1048576

When I compare those values to the my.ini file that I've been manipulating, the max_allowed_packet is:
max_allowed_packet = 16M

...and the wait timeout is:

#innodb_lock_wait_timeout = 50

Now, Phil, something doesn't smell right here. The variables that are listed on the my.ini file don't seem to match what's actually being perceived by system, yes? Is there a discrepancy? BTW: I'm accessing my.ini by highlighting the my.ini option in the WAMP interface.

brucegustPHP DeveloperAuthor Commented:
Changed the settings, Phil, and I was stoked because I figured this was the ultimate way in which to establish some settings that would pave the way for what needed to be done.


Same error.

What do you think?
brucegustPHP DeveloperAuthor Commented:
I wasn't able to get it to work, but I did find a workaround so I was able to accomplish what I needed to get done. Thanks. Phil, for helping me out with the MySQL code that allowed me to directly affect the max_allowed_packet setting and the max_timeout variable.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.