Recently I have been working with Mysql and PhpMyAdmin a lot on Ubuntu, and I have stumbled across a very annoying error, or set of errors. I keep on getting a bunch of random loosely related error messages. These are the errors I get. When I try to log in it sometimes gives me an error
#2003 Cannot log in to the MySQL server
and sometimes it logs me in. Then once I've got in it will randomly take me back to the login page. Sometimes when I have successfully logged in, I manage to get to select a database, and then it gives me

SQL query: 

SELECT  `comment` 
FROM `phpmyadmin`.`pma_column_info`
WHERE db_name = 'datamodels'
AND table_name =  ''
AND column_name = '(db_comment)'

MySQL said: 

#2006 - MySQL server has gone away

where the list of tables should be and then where the structure of the database should be it says

SQL query: 

SELECT  `comment` 
FROM  `phpmyadmin`.`pma_column_info` 
WHERE db_name =  'datamodels'
AND table_name =  ''
AND column_name =  '(db_comment)'

MySQL said: 

#2013 - Lost connection to MySQL server during query

What I'm stumped on is the fact that it is so random and unpredictable. Sometimes it gives me the errors, and sometimes it doesn't

Recommended Answers

All 8 Replies

It looks like the MySQL server and/or the TCP/IP connection on port 3306 do not work properly and have too long reponse times. How high is the average server load (as shown by "top")? If it is above 0.5 most of the time try to add ressources or to move to another machine.

Well, I did top and the average load is about 0.25, But I have a very fast computer, 8 core 2 GHZ Opteron 6128 processor, and 12G of ram. It's a local installation, LAMP. How could I test the activity of port 3306? Thanks for your response.

Another cause might be that - for what reason ever - the session cookies are deleted to early. Try to find the session cookie in your browser after the error has occured - if you can find it and it's not yet expired, my assumption is wrong.

I highly doubt the cookie session idea, because my php code gives the same error, which connects and runs a sql statement within about 0.1 seconds. It was a good idea though. I'm still stumped. :(

Can you access the database using the mysql command line tool?

  1. If you can, then the issue is somewhere in PHP-land.
  2. If you get the same problems using command line mysql, then the problem is somewhere on the database side of the world (including issues with the particular port)
  1. PHP problems. Try re-installing PHP (or/and the PHP-mysql adaptors).
  2. MySql problems.
    • Force MySQL to stop and restart. Maybe reboot the whole machine
    • Use a different port?
    • Create a new user with new permissions and connect with those permissions
    • Create a new database with default behavior and copy the data into that database
    • ... re-install MySQL... being sure to back up any needed data first...

edit: Port issues. You don't say what your platform is, though LAMP is usually a *NIX OS. I've had some issues with where the port thinks it wants to be. Older versions on my OS/X wanted to be in /tmp; newer versions are somewhere else (I forget exactly). Could you be having some kind of port contention problem???

there isnt any 'bad' characters in the database records, unsanitised quotes etc that may mess up the sql ?
probably get negged for asking the obvious, but the obvious SH__ sometimes happens

ok so I tried griswolf's advice, and I realized that I can connect to other databases more successfully than the main database. This is a really frustrating problem, because there are multiple things that I think may be wrong, on the one hand when I connect to mysql using command line, it'll sometimes log me in and sometimes not. Then once I'm in, depending on the database I use, it'll give me the error messages I've described above, or it'll work perfectly. I'm thinking of just starting over with the mysql thing, but I would like to keep my data. Any tutorials/documentation you know of that could help with saving a defunct mysql server's data.

Repeatedly try to use mysqldump until it works. Make the output files distinct each time so you can merge the information if there are partial successes. I'm no database guru though, so there may be a better way. Or, considering @almostbob's point, maybe you are better off dumping one thing at a time, and getting (only) the stuff for which it works, eh?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.