Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 35.3Mb
PDF (A4) - 35.5Mb
PDF (RPM) - 33.8Mb
EPUB - 8.6Mb
HTML Download (TGZ) - 8.4Mb
HTML Download (Zip) - 8.5Mb
HTML Download (RPM) - 7.3Mb
Eclipse Doc Plugin (TGZ) - 9.3Mb
Eclipse Doc Plugin (Zip) - 11.3Mb
Man Pages (TGZ) - 197.9Kb
Man Pages (Zip) - 301.8Kb
Info (Gzip) - 3.2Mb
Info (Zip) - 3.2Mb
Excerpts from this Manual

25.8.7.5 mysql_close()

void mysql_close(MYSQL *mysql)

Description

Closes a previously opened connection. mysql_close() also deallocates the connection handle pointed to by mysql if the handle 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.