Documentation Home
MySQL 8.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 37.7Mb
PDF (A4) - 37.7Mb
PDF (RPM) - 33.8Mb
HTML Download (TGZ) - 8.4Mb
HTML Download (Zip) - 8.4Mb
HTML Download (RPM) - 7.3Mb
Man Pages (TGZ) - 130.0Kb
Man Pages (Zip) - 185.6Kb
Info (Gzip) - 3.3Mb
Info (Zip) - 3.3Mb


Pre-General Availability Draft: 2018-02-20

28.7.7.5 mysql_close()

void mysql_close(MYSQL *mysql)

Description

Closes a previously opened connection. mysql_close() also deallocates the connection handler pointed to by mysql if the handler was allocated automatically by mysql_init() or mysql_connect().

Return Values

None.

Errors

None.


User Comments
  Posted by Benjamin K. on June 10, 2004
the mysql_close command need to stay near the connect command, which he closes or there is a warning like this: Warning: mysql_close(): 5 is not a valid MySQL-Link resource in /foo/bar on line 152
  Posted by Erno Szabados on October 12, 2006
If MySQL pointer was allocated by mysql_init(), and you plan to reuse the connection descriptor, then it is important to set it to NULL after mysql_close(), otherwise the next init will think it's already allocated, then the next the call for mysql_real_connect() will SEGFAULT.

At least, that's what happened to me.

Sign Up Login You must be logged in to post a comment.