-1

I am accessing my MySQL database on AWS using MySQL Workbench. When I execute a query through Workbench or even localhost (from my PHP code) I am getting an error saying:

Mysql server gone away

I went through some of the Stack Overflow articles and which mentioned to check the wait_timeout. My wait_timeout when running Show Variables is set at 28800. I am not sure why I am getting the error.

Mark Amery
  • 143,130
  • 81
  • 406
  • 459
FBP
  • 345
  • 3
  • 15
  • How are the security rules set-up on AWS? What are the rights granted in MySQL to the user you are using to connect? What exactly is the error code and error message? Do you have the same error if the code is running on a EC2 instance? I would also add the tag "AWS" on this question. – Dragos Dec 14 '15 at 15:34
  • Is the php code also trying to access the AWS RDS? or the php code is trying to access a localhost DB ? – Dragos Dec 14 '15 at 15:52
  • Did you try reproducing the error using a locally hosted DB? – Dragos Dec 14 '15 at 15:53
  • @Dragos both MySql workbench and PHP code are accessing the AWS database. The PHP Error and Workbench error are same as below: Error Lost connection to MySQL server during query. MYSQL Server has gone away. The PHP error showed in the debug mode not in normal operation. – FBP Dec 14 '15 at 15:54
  • You might need to increase [`max_allowed_packet`](http://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_max_allowed_packet) – sending a query that is “bigger” than this setting allows, is also a common cause for this error. – CBroe Dec 14 '15 at 15:54
  • @CBroe the query is a simple select query – FBP Dec 14 '15 at 16:00
  • @GoudaElalfy the query is a simple select query but the error on PHP showed in debug mode when the time between the first query and the second query took me around 50-60 seconds – FBP Dec 14 '15 at 16:02
  • 1
    http://dev.mysql.com/doc/refman/5.7/en/gone-away.html lists several possible reasons why this error might occur. – CBroe Dec 14 '15 at 16:05
  • Are you running your PHP code from an EC2 instance, or are you running it from somewhere else? If you're running it from somewhere else (home, an office, etc) then is there a firewall there that could be dropping the connection after seeing no activity for a minute or longer? – Bruce P Dec 14 '15 at 16:48
  • @BruceP I am running it from the code sitting on my laptop for now and not on the instance itself. The RDS however is on AWS. – FBP Dec 15 '15 at 06:03

1 Answers1

0

I had Issue with my workbench settings. The time out settings on workbench itself were too small to cause the connection to drop hence my server was 'going away'. I found my answer here: https://stackoverflow.com/a/12790569/4929688

Community
  • 1
  • 1
FBP
  • 345
  • 3
  • 15