Common Errors When Using MySQL Programs
2953
• You got a timeout from the TCP/IP connection on the client side. This may happen if you have
been using the commands:
mysql_options(..., MYSQL_OPT_READ_TIMEOUT,...)
or
mysql_options(..., MYSQL_OPT_WRITE_TIMEOUT,...)
. In this case increasing the timeout
may help solve the problem.
• You have encountered a timeout on the server side and the automatic reconnection in the client is
disabled (the
reconnect
flag in the
MYSQL
structure is equal to 0).
• You are using a Windows client and the server had dropped the connection (probably because
wait_timeout
[506]
expired) before the command was issued.
The problem on Windows is that in some cases MySQL does not get an error from the OS when
writing to the TCP/IP connection to the server, but instead gets the error when trying to read the
answer from the connection.
Prior to MySQL 5.0.19, even if the
reconnect
flag in the
MYSQL
structure is equal to 1, MySQL
does not automatically reconnect and re-issue the query as it doesn't know if the server did get the
original query or not.
The solution to this is to either do a
mysql_ping()
on the connection if there has been a long time
since the last query (this is what Connector/ODBC does) or set
wait_timeout
[506]
on the
mysqld
server so high that it in practice never times out.
• You can also get these errors if you send a query to the server that is incorrect or too large. If
mysqld
receives a packet that is too large or out of order, it assumes that something has gone
wrong with the client and closes the connection. If you need big queries (for example, if you
are working with big
BLOB
columns), you can increase the query limit by setting the server's
max_allowed_packet
[466]
variable, which has a default value of 1MB. You may also need to
increase the maximum packet size on the client end. More information on setting the packet size is
given in
Section C.5.2.10, “Packet Too Large”
.
An
INSERT
or
REPLACE
statement that inserts a great many rows can also cause these sorts of
errors. Either one of these statements sends a single request to the server irrespective of the number
of rows to be inserted; thus, you can often avoid the error by reducing the number of rows sent per
INSERT
or
REPLACE
.
• You also get a lost connection if you are sending a packet 16MB or larger if your client is older than
4.0.8 and your server is 4.0.8 and above, or the other way around.
• It is also possible to see this error if host name lookups fail (for example, if the DNS server on which
your server or network relies goes down). This is because MySQL is dependent on the host system
for name resolution, but has no way of knowing whether it is working—from MySQL's point of view
the problem is indistinguishable from any other network timeout.
You may also see the
MySQL server has gone away
error if MySQL is started with the
--
skip-networking
[421]
option.
Another networking issue that can cause this error occurs if the MySQL port (default 3306) is blocked
by your firewall, thus preventing any connections at all to the MySQL server.
• You can also encounter this error with applications that fork child processes, all of which try to use
the same connection to the MySQL server. This can be avoided by using a separate connection for
each child process.
• You have encountered a bug where the server died while executing the query.
You can check whether the MySQL server died and restarted by executing
mysqladmin version
and examining the server's uptime. If the client connection was broken because
mysqld
crashed
and restarted, you should concentrate on finding the reason for the crash. Start by checking whether
issuing the query again kills the server again. See
Section C.5.4.2, “What to Do If MySQL Keeps
Crashing”
.
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...