0

I'm trying to append a hush database directly from php.

$mysqli->query(file_get_contents('huge.sql'));

but I'm getting :

Warning: mysqli::query(): MySQL server has gone away in 

I was add those 2 line at the beginning of my php code :

ini_set('mysql.connect_timeout',3000);
ini_set('default_socket_timeout',3000);

Not very helpful...

davidmarko
  • 343
  • 3
  • 17

1 Answers1

0

Unless you're getting an actual error and not a Warning, this doesn't necessarily mean you're doing something wrong.

With PDO for example, this warning can be issued when pooled connections are in use, such as when PHP is running as an Apache Module. There is a similar post here: How to fix the "server has gone away" warning when mysqli reconnects a persistent connection?

If what you're getting is simply a warning, and the query runs fine anyway, then you can either choose to request a persistent mysql connection, or ignore and suppress the warning.

If you're getting an error and your connection is getting terminated, then you should see https://dev.mysql.com/doc/refman/8.0/en/gone-away.html for most common causes of this issue.

nucc1
  • 324
  • 2
  • 8
  • It's not a warning anymore. It might have been a warning in the older PHP versions, but not anymore. – Dharman Jun 17 '22 at 08:21