背景:解决数据库查询超时设置所做的一些实验
一. 读写超时设置实战
a) 读写超时设置测试代码:
<?php
ini_set("memory_limit", "10G");
echo "\nenter test time out\n";
function connect($conf)
{
$host = $conf['host'];
$port = $conf['port'];
$database = $conf['database'];
$username = $conf['username'];
$password = $conf['password'];
$mysqli = mysqli_init();
$mysqli->options(0 /*MYSQL_OPT_CONNECT_TIMEOUT*/ , 1);
$mysqli->options(11 /*MYSQL_OPT_READ_TIMEOUT*/, 1);
$mysqli->options(12 /*MYSQL_OPT_WRITE_TIMEOUT*/, 1);
$mysqli->real_connect($host, $username, $password, $database, $port);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$mysqli->query("set names 'utf8'"); //编码转化
if( !$mysqli ) {
die("could not connect to the database." . $mysqli->connect_errno); //诊断连接错误
}
return $mysqli;
}
function query_sql($connObj, $sql)
{
$retList = array();
$result = $connObj->query($sql);
print_r($result);
if( is_bool($result) ) {
echo "\nWARNING return value is bool variable\n";
var_dump($result);
echo "\n error no : " . $connObj->errno . "\n"; // 返回错误码
echo "\n error info : " . $connObj->error . "\n"; // 返回错误信息
return $result;
}
while( $row = mysqli_fetch_assoc($result) ) {
$retList[] = $row;
}
//end while()
return $retList;
}
$online_conf = array(
'host' => 'xx.xx.xx.xx',
'port' => 1234,
'username' => 'user',
'password' => 'pwd',
'database' => 'order_db',
);
$online_rd_conn = connect($online_conf);
$sql = "select id, user_name, shop_name , `date`, orderid, out_order_id from order_list where user_name = '肖家河' limit 10";
echo "\n$sql\n";
$timeStart = time();
$onlineOrderList = query_sql($online_rd_conn, $sql);
$timeEnd = time();
echo "\nselect cost " . ($timeEnd - $timeStart) . "\n";
print_r($onlineOrderList);
if( empty($onlineOrderList) ) {
echo "\nno order found\n";
exit(0);
}
$online_rd_conn->close();
b) 测试结果
-bash-4.1$ ./bin/php testTimeout.php
enter test time out
select id, user_name, shop_name , `date`, orderid, out_order_id from order_list where user_name = '肖家河' limit 5
WARNING return value is bool variable
bool(false)
error no : 2013
error info : Lost connection to MySQL server during query
select cost 3
no order found
-bash-4.1$
c) mysql_option 字段定义值
enum mysql_option
{
MYSQL_OPT_CONNECT_TIMEOUT, // 0
MYSQL_OPT_COMPRESS,
MYSQL_OPT_NAMED_PIPE,
MYSQL_INIT_COMMAND,
MYSQL_READ_DEFAULT_FILE,
MYSQL_READ_DEFAULT_GROUP,
MYSQL_SET_CHARSET_DIR,
MYSQL_SET_CHARSET_NAME,
MYSQL_OPT_LOCAL_INFILE,
MYSQL_OPT_PROTOCOL,
MYSQL_SHARED_MEMORY_BASE_NAME,
MYSQL_OPT_READ_TIMEOUT, // 11
MYSQL_OPT_WRITE_TIMEOUT, // 12
MYSQL_OPT_USE_RESULT,
MYSQL_OPT_USE_REMOTE_CONNECTION,
MYSQL_OPT_USE_EMBEDDED_CONNECTION,
MYSQL_OPT_GUESS_CONNECTION,
MYSQL_SET_CLIENT_IP,
MYSQL_SECURE_AUTH,
MYSQL_REPORT_DATA_TRUNCATION,
MYSQL_OPT_RECONNECT,
MYSQL_OPT_SSL_VERIFY_SERVER_CERT
}
d) 超时时间说明
MYSQL_OPT_READ_TIMEOUT 因为 mysql 内部也有 2次重试,因此真正的超时间是 3倍的 MYSQL_OPT_READ_TIMEOUT 的值。 【参看下文标红部分】
官网链接 https://dev.mysql.com/doc/refman/8.0/en/mysql-options.html
MYSQL_OPT_READ_TIMEOUT (argument type: unsigned int *)
The timeout in seconds for each attempt to read from the server. There are retries if necessary, so the total effective timeout value is three times the option value. You can set the value so that a lost connection can be detected earlier than the TCP/IP Close_Wait_Timeout value of 10 minutes.
MYSQL_OPT_WRITE_TIMEOUT 内部有一次重试,因此真正的超时间是 2 倍的 MYSQL_OPT_WRITE_TIMEOUT。【参看下文标红部分】
官网链接 https://dev.mysql.com/doc/refman/8.0/en/mysql-options.html
MYSQL_OPT_WRITE_TIMEOUT (argument type: unsigned int *)
The timeout in seconds for each attempt to write to the server. There is a retry if necessary, so the total effective timeout value is two times the option value.
二 . mysql_options()
官网链接 https://dev.mysql.com/doc/refman/8.0/en/mysql-options.html
int mysql_options(MYSQL *mysql, enum mysql_option option, const void *arg)
Can be used to set extra connect options and affect behavior for a connection. This function may be called multiple times to set several options. To retrieve option values, use mysql_get_option()
.
Call mysql_options()
after mysql_init()
and before mysql_connect()
or mysql_real_connect()
.
The option
argument is the option that you want to set; the arg
argument is the value for the option. If the option is an integer, specify a pointer to the value of the integer as the arg
argument.
Options for information such as SSL certificate and key files are used to establish an encrypted connection if such connections are available, but do not enforce any requirement that the connection obtained be encrypted. To require an encrypted connection, use the technique described in Section 27.7.18, “C API Encrypted Connection Support”.
The following list describes the possible options, their effect, and how arg
is used for each option. For option descriptions that indicate arg
is unused, its value is irrelevant; it is conventional to pass 0.
-
MYSQL_DEFAULT_AUTH
(argument type:char *
)The name of the authentication plugin to use.
-
MYSQL_ENABLE_CLEARTEXT_PLUGIN
(argument type:bool *
)Enable the
mysql_clear_password
cleartext authentication plugin. See Section 6.5.1.4, “Client-Side Cleartext Pluggable Authentication”. -
MYSQL_INIT_COMMAND
(argument type:char *
)SQL statement to execute when connecting to the MySQL server. Automatically re-executed if reconnection occurs.
-
MYSQL_OPT_BIND
(argument:char *
)The network interface from which to connect to the server. This is used when the client host has multiple network interfaces. The argument is a host name or IP address (specified as a string).
-
MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS
(argument type:bool *
)Indicate whether the client can handle expired passwords. See Section 6.3.9, “Server Handling of Expired Passwords”.
-
MYSQL_OPT_COMPRESS
(argument: not used)Use the compressed client/server protocol.
-
MYSQL_OPT_CONNECT_ATTR_DELETE
(argument type:char *
)Given a key name, this option deletes a key/value pair from the current set of connection attributes to pass to the server at connect time. The argument is a pointer to a null-terminated string naming the key. Comparison of the key name with existing keys is case-sensitive.
See also the description for the
MYSQL_OPT_CONNECT_ATTR_RESET
option, as well as the description for theMYSQL_OPT_CONNECT_ATTR_ADD
option in the description of themysql_options4()
function. That function description also includes a usage example.The Performance Schema exposes connection attributes through the
session_connect_attrs
andsession_account_connect_attrs
tables. See Section 25.11.9, “Performance Schema Connection Attribute Tables”. -
MYSQL_OPT_CONNECT_ATTR_RESET
(argument not used)This option resets (clears) the current set of connection attributes to pass to the server at connect time.
See also the description for the
MYSQL_OPT_CONNECT_ATTR_DELETE
option, as well as the description for theMYSQL_OPT_CONNECT_ATTR_ADD
option in the description of themysql_options4()
function. That function description also includes a usage example.The Performance Schema exposes connection attributes through the
session_connect_attrs
andsession_account_connect_attrs
tables. See Section 25.11.9, “Performance Schema Connection Attribute Tables”. -
MYSQL_OPT_CONNECT_TIMEOUT
(argument type:unsigned int *
)The connect timeout in seconds.
-
MYSQL_OPT_GET_SERVER_PUBLIC_KEY
(argument type:bool *
)Enables the client to request from the server the public key required for RSA key pair-based password exchange. This option applies to clients that authenticate with the
caching_sha2_password
authentication plugin. For that plugin, the server does not send the public key unless requested. This option is ignored for accounts that do not authenticate with that plugin. It is also ignored if RSA-based password exchange is not used, as is the case when the client connects to the server using a secure connection.If
MYSQL_SERVER_PUBLIC_KEY
is given and specifies a valid public key file, it takes precedence overMYSQL_OPT_GET_SERVER_PUBLIC_KEY
.For information about the
caching_sha2_password
plugin, see Section 6.5.1.3, “Caching SHA-2 Pluggable Authentication”. -
MYSQL_OPT_LOCAL_INFILE
(argument type: optional pointer tounsigned int
)This option affects client-side
LOCAL
capability forLOAD DATA
operations. By default,LOCAL
capability is determined by the default compiled into the MySQL client library (see Section 13.2.7, “LOAD DATA INFILE Syntax”). To control this capability explicitly, invokemysql_options()
to set theMYSQL_OPT_LOCAL_INFILE
option:-
LOCAL
is disabled if the pointer points to anunsigned int
that has a zero value. -
LOCAL
is enabled if no pointer is given or if the pointer points to anunsigned int
that has a nonzero value.
Successful use of a
LOCAL
load operation by a client also requires that the server permits it. -
-
MYSQL_OPT_MAX_ALLOWED_PACKET
(argument:unsigned long *
)This option sets the
max_allowed_packet
system variable. If themysql
argument is non-NULL
, the call sets the session system variable value for that session. Ifmysql
isNULL
, the call sets the global system variable value. -
MYSQL_OPT_NAMED_PIPE
(argument: not used)Use a named pipe to connect to the MySQL server on Windows, if the server permits named-pipe connections.
-
MYSQL_OPT_NET_BUFFER_LENGTH
(argument:unsigned long *
)This option sets the
net_buffer_length
system variable. If themysql
argument is non-NULL
, the call sets the session system variable value for that session. Ifmysql
isNULL
, the call sets the global system variable value. -
MYSQL_OPT_OPTIONAL_RESULTSET_METADATA
(argument type:bool *
)This flag makes result set metadata optional. It is an alternative way of setting the
CLIENT_OPTIONAL_RESULTSET_METADATA
connection flag for themysql_real_connect()
function. For details about managing result set metadata transfer, see Section 27.7.23, “C API Optional Result Set Metadata”. -
MYSQL_OPT_PROTOCOL
(argument type:unsigned int *
)Type of protocol to use. Specify one of the enum values of
mysql_protocol_type
defined inmysql.h
. -
MYSQL_OPT_READ_TIMEOUT
(argument type:unsigned int *
)The timeout in seconds for each attempt to read from the server. There are retries if necessary, so the total effective timeout value is three times the option value. You can set the value so that a lost connection can be detected earlier than the TCP/IP
Close_Wait_Timeout
value of 10 minutes. -
MYSQL_OPT_RECONNECT
(argument type:bool *
)Enable or disable automatic reconnection to the server if the connection is found to have been lost. Reconnect is off by default; this option provides a way to set reconnection behavior explicitly. See Section 27.7.24, “C API Automatic Reconnection Control”.
-
MYSQL_OPT_RETRY_COUNT
(argument type:unsigned int *
)The retry count for I/O-related system calls that are interrupted while connecting to the server or communicating with it. The default value is 1 (1 retry if the initial call is interrupted for 2 tries total).
-
MYSQL_OPT_SSL_CA
(argument type:char *
)The path name of the Certificate Authority (CA) certificate file. This option, if used, must specify the same certificate used by the server.
-
MYSQL_OPT_SSL_CAPATH
(argument type:char *
)The path name of the directory that contains trusted SSL CA certificate files.
-
MYSQL_OPT_SSL_CERT
(argument type:char *
)The path name of the client public key certificate file.
-
MYSQL_OPT_SSL_CIPHER
(argument type:char *
)The list of permitted ciphers for SSL encryption.
-
MYSQL_OPT_SSL_CRL
(argument type:char *
)The path name of the file containing certificate revocation lists.
-
MYSQL_OPT_SSL_CRLPATH
(argument type:char *
)The path name of the directory that contains files containing certificate revocation lists.
-
MYSQL_OPT_SSL_FIPS_MODE
(argument type:unsigned int *
)Controls whether to enable FIPS mode on the client side. The
MYSQL_OPT_SSL_FIPS_MODE
option differs from otherMYSQL_OPT_SSL_
options in that it is not used to establish encrypted connections, but rather to affect which cryptographic operations are permitted. See Section 6.6, “FIPS Support”.xxx
Permitted option values are
SSL_FIPS_MODE_OFF
,SSL_FIPS_MODE_ON
, andSSL_FIPS_MODE_STRICT
.Note
If the OpenSSL FIPS Object Module is not available, the only permitted value for
MYSQL_OPT_SSL_FIPS_MODE
isSSL_FIPS_MODE_OFF
. In this case, settingMYSQL_OPT_SSL_FIPS_MODE
toSSL_FIPS_MODE_ON
orSSL_FIPS_MODE_STRICT
causes the client to produce a warning at startup and to operate in non-FIPS mode. -
MYSQL_OPT_SSL_KEY
(argument type:char *
)The path name of the client private key file.
-
MYSQL_OPT_SSL_MODE
(argument type:unsigned int *
)The security state to use for the connection to the server:
SSL_MODE_DISABLED
,SSL_MODE_PREFERRED
,SSL_MODE_REQUIRED
,SSL_MODE_VERIFY_CA
,SSL_MODE_VERIFY_IDENTITY
. The default isSSL_MODE_PREFERRED
. These modes are the permitted values of themysql_ssl_mode
enumeration defined inmysql.h
. For more information about the security states, see the description of--ssl-mode
in Section 6.4.2, “Command Options for Encrypted Connections”. -
MYSQL_OPT_TLS_VERSION
(argument type:char *
)The protocols permitted by the client for encrypted connections. The value is a comma-separated list containing one or more protocol names. The protocols that can be named for this option depend on the SSL library used to compile MySQL. For details, see Section 6.4.6, “Encrypted Connection Protocols and Ciphers”.
-
MYSQL_OPT_USE_RESULT
(argument: not used)This option is unused.
-
MYSQL_OPT_WRITE_TIMEOUT
(argument type:unsigned int *
)The timeout in seconds for each attempt to write to the server. There is a retry if necessary, so the total effective timeout value is two times the option value.
-
MYSQL_PLUGIN_DIR
(argument type:char *
)The directory in which to look for client plugins.
-
MYSQL_READ_DEFAULT_FILE
(argument type:char *
)Read options from the named option file instead of from
my.cnf
. -
MYSQL_READ_DEFAULT_GROUP
(argument type:char *
)Read options from the named group from
my.cnf
or the file specified withMYSQL_READ_DEFAULT_FILE
. -
MYSQL_REPORT_DATA_TRUNCATION
(argument type:bool *
)Enable or disable reporting of data truncation errors for prepared statements using the
error
member ofMYSQL_BIND
structures. (Default: enabled.) -
MYSQL_SERVER_PUBLIC_KEY
(argument type:char *
)The path name of the file containing a client-side copy of the public key required by the server for RSA key pair-based password exchange. The file must be in PEM format. This option applies to clients that authenticate with the
sha256_password
orcaching_sha2_password
authentication plugin. This option is ignored for accounts that do not authenticate with one of those plugins. It is also ignored if RSA-based password exchange is not used, as is the case when the client connects to the server using a secure connection.If
MYSQL_SERVER_PUBLIC_KEY
is given and specifies a valid public key file, it takes precedence overMYSQL_OPT_GET_SERVER_PUBLIC_KEY
.For information about the
sha256_password
andcaching_sha2_password
plugins, see Section 6.5.1.2, “SHA-256 Pluggable Authentication”, and Section 6.5.1.3, “Caching SHA-2 Pluggable Authentication”. -
MYSQL_SET_CHARSET_DIR
(argument type:char *
)The path name of the directory that contains character set definition files.
-
MYSQL_SET_CHARSET_NAME
(argument type:char *
)The name of the character set to use as the default character set. The argument can be
MYSQL_AUTODETECT_CHARSET_NAME
to cause the character set to be autodetected based on the operating system setting (see Section 10.4, “Connection Character Sets and Collations”). -
MYSQL_SHARED_MEMORY_BASE_NAME
(argument type:char *
)The name of the shared-memory object for communication to the server on Windows, if the server supports shared-memory connections. Specify the same value as the
--shared-memory-base-name
option used for the mysqld server you want to connect to.
The client
group is always read if you use MYSQL_READ_DEFAULT_FILE
or MYSQL_READ_DEFAULT_GROUP
.
The specified group in the option file may contain the following options.
Option | Description |
---|---|
character-sets-dir= |
The directory where character sets are installed. |
compress |
Use the compressed client/server protocol. |
connect-timeout= |
The connect timeout in seconds. On Linux this timeout is also used for waiting for the first answer from the server. |
database= |
Connect to this database if no database was specified in the connect command. |
debug |
Debug options. |
default-character-set= |
The default character set to use. |
disable-local-infile |
Disable use of LOAD DATA LOCAL INFILE . |
enable-cleartext-plugin |
Enable the mysql_clear_password cleartext authentication plugin. |
host= |
Default host name. |
init-command= |
Statement to execute when connecting to MySQL server. Automatically re-executed if reconnection occurs. |
interactive-timeout= |
Same as specifying CLIENT_INTERACTIVE to mysql_real_connect() . See Section 27.7.7.54, “mysql_real_connect()”. |
local-infile[={0|1}] |
If no argument or nonzero argument, enable use of LOAD DATA LOCAL ; otherwise disable. |
max_allowed_packet= |
Maximum size of packet that client can read from server. |
multi-queries , multi-results |
Enable multiple result sets from multiple-statement executions or stored procedures. |
multi-statements |
Enable the client to send multiple statements in a single string (separated by ; characters). |
password= |
Default password. |
pipe |
Use named pipes to connect to a MySQL server on Windows. |
port= |
Default port number. |
protocol={TCP|SOCKET|PIPE|MEMORY} |
The protocol to use when connecting to the server. |
return-found-rows |
Tell mysql_info() to return found rows instead of updated rows when using UPDATE . |
shared-memory-base-name= |
Shared-memory name to use to connect to server. |
socket={ |
Default socket file. |
ssl-ca= |
Certificate Authority file. |
ssl-capath= |
Certificate Authority directory. |
ssl-cert= |
Certificate file. |
ssl-cipher= |
Permissible SSL ciphers. |
ssl-key= |
Key file. |
timeout= |
Like connect-timeout . |
user |
Default user. |
timeout
has been replaced by connect-timeout
, but timeout
is still supported for backward compatibility.
For more information about option files used by MySQL programs, see Section 4.2.6, “Using Option Files”.
Zero for success. Nonzero if you specify an unknown option.
The following mysql_options()
calls request the use of compression in the client/server protocol, cause options to be read from the [odbc]
group in option files, and disable transaction autocommit mode:
MYSQL mysql;
mysql_init(&mysql);
mysql_options(&mysql,MYSQL_OPT_COMPRESS,0);
mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"odbc");
mysql_options(&mysql,MYSQL_INIT_COMMAND,"SET autocommit=0");
if (!mysql_real_connect(&mysql,"host","user","passwd","database",0,NULL,0))
{
fprintf(stderr, "Failed to connect to database: Error: %s\n",
mysql_error(&mysql));
}
三 . [错误码]B.4 Client Error Codes and Messages
官网链接 https://dev.mysql.com/doc/refman/8.0/en/error-messages-client.html
Client error information comes from the following source files:
-
The Error values and the symbols in parentheses correspond to definitions in the
include/errmsg.h
MySQL source file. -
The Message values correspond to the error messages that are listed in the
libmysql/errmsg.c
file.%d
and%s
represent numbers and strings, respectively, that are substituted into the messages when they are displayed.
Because updates are frequent, it is possible that those files will contain additional error information not listed here.
-
Error:
2000
(CR_UNKNOWN_ERROR
)Message: Unknown MySQL error
-
Error:
2001
(CR_SOCKET_CREATE_ERROR
)Message: Can't create UNIX socket (%d)
-
Error:
2002
(CR_CONNECTION_ERROR
)Message: Can't connect to local MySQL server through socket '%s' (%d)
-
Error:
2003
(CR_CONN_HOST_ERROR
)Message: Can't connect to MySQL server on '%s' (%d)
-
Error:
2004
(CR_IPSOCK_ERROR
)Message: Can't create TCP/IP socket (%d)
-
Error:
2005
(CR_UNKNOWN_HOST
)Message: Unknown MySQL server host '%s' (%d)
-
Error:
2006
(CR_SERVER_GONE_ERROR
)Message: MySQL server has gone away
-
Error:
2007
(CR_VERSION_ERROR
)Message: Protocol mismatch; server version = %d, client version = %d
-
Error:
2008
(CR_OUT_OF_MEMORY
)Message: MySQL client ran out of memory
-
Error:
2009
(CR_WRONG_HOST_INFO
)Message: Wrong host info
-
Error:
2010
(CR_LOCALHOST_CONNECTION
)Message: Localhost via UNIX socket
-
Error:
2011
(CR_TCP_CONNECTION
)Message: %s via TCP/IP
-
Error:
2012
(CR_SERVER_HANDSHAKE_ERR
)Message: Error in server handshake
-
Error:
2013
(CR_SERVER_LOST
)Message: Lost connection to MySQL server during query
-
Error:
2014
(CR_COMMANDS_OUT_OF_SYNC
)Message: Commands out of sync; you can't run this command now
-
Error:
2015
(CR_NAMEDPIPE_CONNECTION
)Message: Named pipe: %s
-
Error:
2016
(CR_NAMEDPIPEWAIT_ERROR
)Message: Can't wait for named pipe to host: %s pipe: %s (%lu)
-
Error:
2017
(CR_NAMEDPIPEOPEN_ERROR
)Message: Can't open named pipe to host: %s pipe: %s (%lu)
-
Error:
2018
(CR_NAMEDPIPESETSTATE_ERROR
)Message: Can't set state of named pipe to host: %s pipe: %s (%lu)
-
Error:
2019
(CR_CANT_READ_CHARSET
)Message: Can't initialize character set %s (path: %s)
-
Error:
2020
(CR_NET_PACKET_TOO_LARGE
)Message: Got packet bigger than 'max_allowed_packet' bytes
-
Error:
2021
(CR_EMBEDDED_CONNECTION
)Message: Embedded server
-
Error:
2022
(CR_PROBE_SLAVE_STATUS
)Message: Error on SHOW SLAVE STATUS:
-
Error:
2023
(CR_PROBE_SLAVE_HOSTS
)Message: Error on SHOW SLAVE HOSTS:
-
Error:
2024
(CR_PROBE_SLAVE_CONNECT
)Message: Error connecting to slave:
-
Error:
2025
(CR_PROBE_MASTER_CONNECT
)Message: Error connecting to master:
-
Error:
2026
(CR_SSL_CONNECTION_ERROR
)Message: SSL connection error: %s
-
Error:
2027
(CR_MALFORMED_PACKET
)Message: Malformed packet
-
Error:
2028
(CR_WRONG_LICENSE
)Message: This client library is licensed only for use with MySQL servers having '%s' license
-
Error:
2029
(CR_NULL_POINTER
)Message: Invalid use of null pointer
-
Error:
2030
(CR_NO_PREPARE_STMT
)Message: Statement not prepared
-
Error:
2031
(CR_PARAMS_NOT_BOUND
)Message: No data supplied for parameters in prepared statement
-
Error:
2032
(CR_DATA_TRUNCATED
)Message: Data truncated
-
Error:
2033
(CR_NO_PARAMETERS_EXISTS
)Message: No parameters exist in the statement
-
Error:
2034
(CR_INVALID_PARAMETER_NO
)Message: Invalid parameter number
The column number for
mysql_stmt_fetch_column()
was invalid.The parameter number for
mysql_stmt_send_long_data()
was invalid.A key name was empty or the amount of connection attribute data for
mysql_options4()
exceeds the 64KB limit. -
Error:
2035
(CR_INVALID_BUFFER_USE
)Message: Can't send long data for non-string/non-binary data types (parameter: %d)
-
Error:
2036
(CR_UNSUPPORTED_PARAM_TYPE
)Message: Using unsupported buffer type: %d (parameter: %d)
-
Error:
2037
(CR_SHARED_MEMORY_CONNECTION
)Message: Shared memory: %s
-
Error:
2038
(CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR
)Message: Can't open shared memory; client could not create request event (%lu)
-
Error:
2039
(CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR
)Message: Can't open shared memory; no answer event received from server (%lu)
-
Error:
2040
(CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR
)Message: Can't open shared memory; server could not allocate file mapping (%lu)
-
Error:
2041
(CR_SHARED_MEMORY_CONNECT_MAP_ERROR
)Message: Can't open shared memory; server could not get pointer to file mapping (%lu)
-
Error:
2042
(CR_SHARED_MEMORY_FILE_MAP_ERROR
)Message: Can't open shared memory; client could not allocate file mapping (%lu)
-
Error:
2043
(CR_SHARED_MEMORY_MAP_ERROR
)Message: Can't open shared memory; client could not get pointer to file mapping (%lu)
-
Error:
2044
(CR_SHARED_MEMORY_EVENT_ERROR
)Message: Can't open shared memory; client could not create %s event (%lu)
-
Error:
2045
(CR_SHARED_MEMORY_CONNECT_ABANDONED_ERROR
)Message: Can't open shared memory; no answer from server (%lu)
-
Error:
2046
(CR_SHARED_MEMORY_CONNECT_SET_ERROR
)Message: Can't open shared memory; cannot send request event to server (%lu)
-
Error:
2047
(CR_CONN_UNKNOW_PROTOCOL
)Message: Wrong or unknown protocol
-
Error:
2048
(CR_INVALID_CONN_HANDLE
)Message: Invalid connection handle
-
Error:
2049
(CR_UNUSED_1
)Message: Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)
-
Error:
2050
(CR_FETCH_CANCELED
)Message: Row retrieval was canceled by mysql_stmt_close() call
-
Error:
2051
(CR_NO_DATA
)Message: Attempt to read column without prior row fetch
-
Error:
2052
(CR_NO_STMT_METADATA
)Message: Prepared statement contains no metadata
-
Error:
2053
(CR_NO_RESULT_SET
)Message: Attempt to read a row while there is no result set associated with the statement
-
Error:
2054
(CR_NOT_IMPLEMENTED
)Message: This feature is not implemented yet
-
Error:
2055
(CR_SERVER_LOST_EXTENDED
)Message: Lost connection to MySQL server at '%s', system error: %d
-
Error:
2056
(CR_STMT_CLOSED
)Message: Statement closed indirectly because of a preceding %s() call
-
Error:
2057
(CR_NEW_STMT_METADATA
)Message: The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again
-
Error:
2058
(CR_ALREADY_CONNECTED
)Message: This handle is already connected. Use a separate handle for each connection.
-
Error:
2059
(CR_AUTH_PLUGIN_CANNOT_LOAD
)Message: Authentication plugin '%s' cannot be loaded: %s
-
Error:
2060
(CR_DUPLICATE_CONNECTION_ATTR
)Message: There is an attribute with the same name already
A duplicate connection attribute name was specified for
mysql_options4()
. -
Error:
2061
(CR_AUTH_PLUGIN_ERR
)Message: Authentication plugin '%s' reported error: %s
-
Error:
2062
(CR_INSECURE_API_ERR
)Message: Insecure API function call: '%s' Use instead: '%s'
An insecure function call was detected. Modify the application to use the suggested alternative function instead.
-
Error:
2063
(CR_FILE_NAME_TOO_LONG
)Message: File name is too long
CR_FILE_NAME_TOO_LONG
was added in 8.0.1. -
Error:
2064
(CR_SSL_FIPS_MODE_ERR
)Message: Set FIPS mode ON/STRICT failed
CR_SSL_FIPS_MODE_ERR
was added in 8.0.11.
四 . Connectors and APIs
官网链接 https://dev.mysql.com/doc/refman/8.0/en/connectors-apis.html
Table 27.1 MySQL APIs and Interfaces
Environment | API | Type | Notes |
---|---|---|---|
Ada | GNU Ada MySQL Bindings | libmysqlclient |
See MySQL Bindings for GNU Ada |
C | C API | libmysqlclient |
See Section 27.7, “MySQL C API”. |
C | Connector/C | Replacement for libmysqlclient |
See MySQL Connector/C Developer Guide. |
C++ | Connector/C++ | libmysqlclient |
See MySQL Connector/C++ 8.0 Developer Guide. |
MySQL++ | libmysqlclient |
See MySQL++ website. | |
MySQL wrapped | libmysqlclient |
See MySQL wrapped. | |
Cocoa | MySQL-Cocoa | libmysqlclient |
Compatible with the Objective-C Cocoa environment. Seehttp://mysql-cocoa.sourceforge.net/ |
D | MySQL for D | libmysqlclient |
See MySQL for D. |
Eiffel | Eiffel MySQL | libmysqlclient |
See Section 27.13, “MySQL Eiffel Wrapper”. |
Erlang | erlang-mysql-driver |
libmysqlclient |
See erlang-mysql-driver . |
Haskell | Haskell MySQL Bindings | Native Driver | See Brian O'Sullivan's pure Haskell MySQL bindings. |
hsql-mysql |
libmysqlclient |
See MySQL driver for Haskell. | |
Java/JDBC | Connector/J | Native Driver | See MySQL Connector/J 5.1 Developer Guide. |
Kaya | MyDB | libmysqlclient |
See MyDB. |
Lua | LuaSQL | libmysqlclient |
See LuaSQL. |
.NET/Mono | Connector/NET | Native Driver | See MySQL Connector/NET Developer Guide. |
Objective Caml | OBjective Caml MySQL Bindings | libmysqlclient |
See MySQL Bindings for Objective Caml. |
Octave | Database bindings for GNU Octave | libmysqlclient |
See Database bindings for GNU Octave. |
ODBC | Connector/ODBC | libmysqlclient |
See MySQL Connector/ODBC Developer Guide. |
Perl | DBI /DBD::mysql |
libmysqlclient |
See Section 27.9, “MySQL Perl API”. |
Net::MySQL |
Native Driver | See Net::MySQL at CPAN |
|
PHP | mysql , ext/mysql interface (deprecated) |
libmysqlclient |
See Original MySQL API. |
mysqli , ext/mysqli interface |
libmysqlclient |
See MySQL Improved Extension. | |
PDO_MYSQL |
libmysqlclient |
See MySQL Functions (PDO_MYSQL). | |
PDO mysqlnd | Native Driver | ||
Python | Connector/Python | Native Driver | See MySQL Connector/Python Developer Guide. |
Python | Connector/Python C Extension | libmysqlclient |
See MySQL Connector/Python Developer Guide. |
MySQLdb | libmysqlclient |
See Section 27.10, “MySQL Python API”. | |
Ruby | MySQL/Ruby | libmysqlclient |
Uses libmysqlclient . See Section 27.11.1, “The MySQL/Ruby API”. |
Ruby/MySQL | Native Driver | See Section 27.11.2, “The Ruby/MySQL API”. | |
Scheme | Myscsh |
libmysqlclient |
See Myscsh . |
SPL | sql_mysql |
libmysqlclient |
See sql_mysql for SPL. |
Tcl | MySQLtcl | libmysqlclient |
See Section 27.12, “MySQL Tcl API”. |
更多信息 : https://blog.csdn.net/heiyeshuwu/article/details/5869813