Documentation Home
MySQL 5.5 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 27.1Mb
PDF (A4) - 27.2Mb
PDF (RPM) - 25.7Mb
HTML Download (TGZ) - 6.5Mb
HTML Download (Zip) - 6.6Mb
HTML Download (RPM) - 5.6Mb
Man Pages (TGZ) - 158.5Kb
Man Pages (Zip) - 262.1Kb
Info (Gzip) - 2.6Mb
Info (Zip) - 2.6Mb
Excerpts from this Manual

MySQL 5.5 Reference Manual  /  Errors, Error Codes, and Common Problems  /  Error Message Sources and Components

B.1 Error Message Sources and Components

This section discusses how error messages originate within MySQL and the components they contain.

Error Message Sources

Error messages can originate on the server side or the client side:

  • On the server side, error messages may occur during the startup and shutdown processes, as a result of issues that occur during SQL statement execution, and so forth.

    • The MySQL server writes some error messages to its error log. These indicate issues of interest to database administrators or that require DBA action.

    • The server sends other error messages to client programs. These indicate issues pertaining only to a particular client. The MySQL client library takes errors received from the server and makes them available to the host client program.

  • Client-side error messages are generated from within the MySQL client library, usually involving problems communicating with the server.

Example server-side error messages written to the error log:

  • This message produced during the startup process provides a status or progress indicator:

    181009  7:43:37 [Note] Event Scheduler: scheduler
    thread started with id 1
  • This message indicates an issue that requires DBA action:

    181009 3:20:39 [ERROR] Can't open the mysql.plugin
    table. Please run mysql_upgrade to create it.

Example server-side error message sent to client programs, as displayed by the mysql client:

mysql> SELECT * FROM no_such_table;
ERROR 1146 (42S02): Table 'test.no_such_table' doesn't exist

Example client-side error message originating from within the client library, as displayed by the mysql client:

shell> mysql -h no-such-host
ERROR 2005 (HY000): Unknown MySQL server host 'no-such-host' (0)

Whether an error originates from within the client library or is received from the server, a MySQL client program may respond in varying ways. As just illustrated, the client may display the error message so the user can take corrective measures. The client may instead internally attempt to resolve or retry a failed operation, or take other action.

Error Message Components

When an error occurs, error information includes several components: an error code, SQLSTATE value, and message string. These components have the following characteristics:

  • Error code: This value is numeric. It is MySQL-specific and is not portable to other database systems.

    Each error number has a corresponding symbolic value. Examples:

    Error codes are stable across General Availability (GA) releases of a given MySQL series. Before a series reaches GA status, new codes may still be under development and are subject to change.

  • SQLSTATE value: This value is a five-character string (for example, '42S02'). SQLSTATE values are taken from ANSI SQL and ODBC and are more standardized than the numeric error codes. The first two characters of an SQLSTATE value indicate the error class:

    • Class = '00' indicates success.

    • Class = '01' indicates a warning.

    • Class = '02' indicates not found. This is relevant within the context of cursors and is used to control what happens when a cursor reaches the end of a data set. This condition also occurs for SELECT ... INTO var_list statements that retrieve no rows.

    • Class > '02' indicates an exception.

    For server-side errors, not all MySQL error numbers have corresponding SQLSTATE values. In these cases, 'HY000' (general error) is used.

    For client-side errors, the SQLSTATE value is always 'HY000' (general error), so it is not meaningful for distinguishing one client error from another.

  • Message string: This string provides a textual description of the error.


User Comments
User comments in this section are, as the name implies, provided by MySQL users. The MySQL documentation team is not responsible for, nor do they endorse, any of the information provided here.
Sign Up Login You must be logged in to post a comment.