I need to import a database into a freshly created CentOS 5 virtual machine. However, whenever I run the import command on the console, it stops working in about a minute and I get the error message:

ERROR 2006 (HY00) at line 818: MySQL server has gone away

The only place that MySQL looks for my.cnf (as far as I can tell) is /etc, and I changed the timeout in that configuration, but it doesn't seem to have had any effect. Yet if I make a syntax error, it seems that MySQL is sensitive to that.

My feeling is that there must be a some other .cnf file that is being used after the one that I am modifying, but I can't seem to find it.

Does anyone have any ideas of what else I can do to try to solve this problem?

  • There are 3 or 4 places that MySQL looks for .cnf files on startup, in Linux installations. See this: MySQL: Using Option Files Sep 25 '12 at 19:48
  • " I changed the timeout in that configuration" which timeout was it?
    – DTest
    Sep 25 '12 at 19:53
  • wait_timeout and interactive_timeout Sep 25 '12 at 20:31
  • ypercube, let me walk through those locations. Thanks for sending me to that page. I haven't ran into that one yet. Sep 25 '12 at 20:33
  • Sorry for the delay; a few things got in the way of my working on this issue. I have looked at every entry in your lin, ypercube, and I couldn't find another file except for /etc/my.cnf Oct 1 '12 at 22:23

You can run this command "mysql --help",and you can find something like

Default options are read from the following files in the given order:
C:\WINDOWS\my.ini C:\WINDOWS\my.cnf C:\my.ini C:\my.cnf C:\Program Files\MySQL\M
ySQL Server 5.5\my.ini C:\Program Files\MySQL\MySQL Server 5.5\my.cnf

There is also a manual page talking about MySQL server has gone away

  • Okay, I have run mysql --help and only one of the files that are listed in the default options exists. I am going to try to walk down that link that you added here. Oct 2 '12 at 0:51
  • Thanks. Although your answer didn't give me the direct solution, it did lead me in the right direction, so I marked it as the solution. Oct 2 '12 at 2:39

I found what the problem was.

In centos, the script that runs mysqld is found in /etc/init.d/mysqld This script sets STOPTIMEOUT=60 at line 30. This was the source of the 60 second time limit. The global config file in /etc/init/my.cnf was read first, but then it was overwritten by this script. These settings could be overwritten, according to the script, in /etc/sysconfig/mysqld. These are locations not found in mysql --help.

Man, was this overly difficult.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.