21.1. Interpreting Error Messages


If problems occur when you attempt to connect to MySQL Server with a client program or while the server attempts to execute the SQL statements that you send to it, MySQL produces diagnostic messages. Clients can display this information to assist you in troubleshooting and resolving problems.

Diagnostics might be error messages to indicate serious problems or warning messages to indicate less severe problems. MySQL provides diagnostic information in the following ways:

  • An error message is returned for statements that fail:

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

    These messages typically have three components:

    • A MySQL-specific error code.

    • An SQLSTATE error code. These codes are defined by standard SQL and ODBC.

    • A text message that describes the problem.

  • An information string is returned by statements that affect multiple rows. This string provides a summary of the statement outcome:

     mysql> INSERT INTO integers VALUES ('abc'), (-5), (NULL); Query OK, 3 rows affected, 3 warnings (0.00 sec) Records: 3  Duplicates: 0  Warnings: 3 

  • An operating system-level error might occur:

     mysql> CREATE TABLE CountryCopy SELECT * FROM Country; ERROR 1 (HY000): Can't create/write to file './world/CountryCopy.frm' (Errcode: 13) 

For cases such as the preceding SELECT from a non-existent table, where all three error values are displayed, you can simply look at the information provided to see what the problem was. In other cases, all information might not be displayed. The information string for multiple-row statements is a summary, not a complete listing of diagnostics. An operating system error includes an Errcode number that might have a system-specific meaning.

You can use the following means to obtain assistance in interpreting diagnostic information:

  • The SHOW WARNINGS and SHOW ERRORS statements display warning and error information for statements that produce diagnostic information.

  • The perror command-line utility displays the meaning of operating system-related error codes.

  • There is a chapter in the MySQL Reference Manual that lists error codes and messages.



MySQL 5 Certification Study Guide
MySQL 5.0 Certification Study Guide
ISBN: 0672328127
EAN: 2147483647
Year: 2006
Pages: 312

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net