MySql 中文参考指南

1.6 How to Report Bugs or Problems

在提交有关某个问题的错误报告之前,请先尝试验证它是一个错误,并且之前没有报告过:

Before posting a bug report about a problem, please try to verify that it is a bug and that it has not been reported already:

  1. Start by searching the MySQL online manual at [role="bare"https://dev.mysql.com/doc/]. We try to keep the manual up to date by updating it frequently with solutions to newly found problems. In addition, the release notes accompanying the manual can be particularly useful since it is quite possible that a newer version contains a solution to your problem. The release notes are available at the location just given for the manual.

  2. If you get a parse error for an SQL statement, please check your syntax closely. If you cannot find something wrong with it, it is extremely likely that your current version of MySQL Server doesn’t support the syntax you are using. If you are using the current version and the manual doesn’t cover the syntax that you are using, MySQL Server doesn’t support your statement.

如果手册中包含你正在使用的语法,但你所使用的 MySQL Server 版本较旧,则你应检查 MySQL 更改历史记录以查看何时实施语法。在这种情况下,可以选择升级到较新版本的 MySQL Server。

If the manual covers the syntax you are using, but you have an older version of MySQL Server, you should check the MySQL change history to see when the syntax was implemented. In this case, you have the option of upgrading to a newer version of MySQL Server.

  1. For solutions to some common problems, see Section B.3, “Problems and Common Errors”.

  2. Search the bugs database at http://bugs.mysql.com/ to see whether the bug has been reported and fixed.

  3. You can also use http://www.mysql.com/search/ to search all the Web pages (including the manual) that are located at the MySQL website.

如果您在手册、错误数据库或邮件列表存档中找不到答案,请咨询您当地的 MySQL 专家。如果您仍然找不到问题的答案,请按照以下指南报告错误。

If you cannot find an answer in the manual, the bugs database, or the mailing list archives, check with your local MySQL expert. If you still cannot find an answer to your question, please use the following guidelines for reporting the bug.

  1. 报告错误的通常方法是访问 http://bugs.mysql.com/,这是我们的错误数据库的地址。此数据库是公开的,任何人都可以浏览和搜索。如果你登录到系统,你可以输入新的报告。

The normal way to report bugs is to visit http://bugs.mysql.com/, which is the address for our bugs database. This database is public and can be browsed and searched by anyone. If you log in to the system, you can enter new reports.

  1. http://bugs.mysql.com/ 的错误数据库中发布并针对给定版本更正的错误将在发行说明中注明。

Bugs posted in the bugs database at http://bugs.mysql.com/ that are corrected for a given release are noted in the release notes.

如果您在 MySQL Server 中发现了一个安全漏洞,请发送一封电子邮件至 < link:mailto:secalert_us@oracle.com[secalert_us@oracle.com]> ,立即告知我们。例外情况:支持客户应将所有问题(包括安全漏洞)报告给 http://support.oracle.com/ 的 Oracle 支持服务。

If you find a security bug in MySQL Server, please let us know immediately by sending an email message to <link:mailto:secalert_us@oracle.com[secalert_us@oracle.com]>. Exception: Support customers should report all problems, including security bugs, to Oracle Support at http://support.oracle.com/.

  1. 要与其他用户讨论问题,可以使用 MySQL Community Slack

To discuss problems with other users, you can use the MySQL Community Slack.

编写一份好的缺陷报告需要耐心,但从一开始就正确地完成它可以为您和我们节省时间。一份好的缺陷报告应包含该缺陷的完整测试用例,它很可能使我们在下个版本中修复该缺陷。本部分将帮助您正确撰写您的报告,这样您就可以避免浪费时间去做对我们帮助不大或完全没帮助的事情。请仔细阅读本部分,并确保报告中包含此处描述的所有信息。

Writing a good bug report takes patience, but doing it right the first time saves time both for us and for yourself. A good bug report, containing a full test case for the bug, makes it very likely that we will fix the bug in the next release. This section helps you write your report correctly so that you do not waste your time doing things that may not help us much or at all. Please read this section carefully and make sure that all the information described here is included in your report.

您最好使用 MySQL 服务器的最新生产版本或开发版本测试问题,然后再发布。任何人都应该可以通过 mysql test < script_file 上的测试用例或通过运行缺陷报告中包含的 shell 或 Perl 脚本来重复该缺陷。我们能够重复出现的任何缺陷都有很大机会在下一个 MySQL 版本中修复。

Preferably, you should test the problem using the latest production or development version of MySQL Server before posting. Anyone should be able to repeat the bug by just using mysql test < script_file on your test case or by running the shell or Perl script that you include in the bug report. Any bug that we are able to repeat has a high chance of being fixed in the next MySQL release.

  1. 在错误报告中包含对问题进行很好的描述将很有帮助。也就是说,举一个导致问题的所做一切的例子,并准确详细地描述问题本身。最好的报告是包含一个完整的示例,说明如何重现错误或问题。参见 Section 7.9, “Debugging MySQL”

It is most helpful when a good description of the problem is included in the bug report. That is, give a good example of everything you did that led to the problem and describe, in exact detail, the problem itself. The best reports are those that include a full example showing how to reproduce the bug or problem. See Section 7.9, “Debugging MySQL”.

请记住,对于包含过多信息的报告,我们有可能做出响应,但对于包含过少信息的报告,我们不可能做出响应。人们经常省略事实,因为他们认为自己知道问题的起因,并假设某些细节无关紧要。需要遵循的一个好原则是,如果您对陈述某事犹豫不决,请陈述出来。在报告中多写几行比在我们需要要求您提供初始报告中缺少的信息时较长时间等待答案更快速且不那么麻烦。

Remember that it is possible for us to respond to a report containing too much information, but not to one containing too little. People often omit facts because they think they know the cause of a problem and assume that some details do not matter. A good principle to follow is that if you are in doubt about stating something, state it. It is faster and less troublesome to write a couple more lines in your report than to wait longer for the answer if we must ask you to provide information that was missing from the initial report.

在 bug 报告中常见的错误是:(a) 没有包括你所用的 MySQL 发行版的版本号,以及 (b) 没有完整描述安装了 MySQL 服务器的平台(包括平台类型和版本号)。这些是非常重要的信息,在 100 个中有 99 次,没有它们,bug 报告都是没用的。许多时候,我们会收到这样的问题:“为什么这个功能对我不起作用?”然后我们发现该请求的功能并未在该 MySQL 版本中实现,或者报告中描述的 bug 已在较新版本中修复。错误通常与平台相关。在这种情况下,如果没有操作系统和平台的版本号,我们几乎不可能修复任何内容。

The most common errors made in bug reports are (a) not including the version number of the MySQL distribution that you use, and (b) not fully describing the platform on which the MySQL server is installed (including the platform type and version number). These are highly relevant pieces of information, and in 99 cases out of 100, the bug report is useless without them. Very often we get questions like, “Why doesn’t this work for me?” Then we find that the feature requested wasn’t implemented in that MySQL version, or that a bug described in a report has been fixed in newer MySQL versions. Errors often are platform-dependent. In such cases, it is next to impossible for us to fix anything without knowing the operating system and the version number of the platform.

如果你是从源代码编译 MySQL 的,请记住,如果它与问题相关,还要提供有关你的编译器的信息。人们经常发现编译器中的错误,并认为这个问题与 MySQL 相关。大多数编译器都在不断开发中,并且版本之间不断变得更好。要确定你的问题是否取决于你的编译器,我们需要知道你使用了哪个编译器。请注意,每一个编译问题都应该被视为一个 bug,并相应地进行报告。

If you compiled MySQL from source, remember also to provide information about your compiler if it is related to the problem. Often people find bugs in compilers and think the problem is MySQL-related. Most compilers are under development all the time and become better version by version. To determine whether your problem depends on your compiler, we need to know what compiler you used. Note that every compiling problem should be regarded as a bug and reported accordingly.

如果一个程序产生了一个错误消息,则在报告中包含这个消息非常重要。如果我们尝试从存档中搜索一些东西,那么报告的错误消息与程序产生的错误消息完全匹配会更好。(即使是大小写也应注意。)最好将完整的错误消息复制并粘贴到你的报告中。你永远不应该尝试从内存中复制该消息。

If a program produces an error message, it is very important to include the message in your report. If we try to search for something from the archives, it is better that the error message reported exactly matches the one that the program produces. (Even the lettercase should be observed.) It is best to copy and paste the entire error message into your report. You should never try to reproduce the message from memory.

  1. 如果你在 Connector/ODBC (MyODBC) 中遇到问题,请尝试生成一个跟踪文件并随报告一起发送。参见 How to Report Connector/ODBC Problems or Bugs

If you have a problem with Connector/ODBC (MyODBC), please try to generate a trace file and send it with your report. See How to Report Connector/ODBC Problems or Bugs.

如果您的报告包括使用 mysql 命令行工具运行的测试用例中的长查询输出行,您可以通过使用 —​vertical 选项或 \G 语句终止符使输出更具可读性。本节后文中的 EXPLAIN SELECT 实例演示了如何使用 \G

If your report includes long query output lines from test cases that you run with the mysql command-line tool, you can make the output more readable by using the —​vertical option or the \G statement terminator. The EXPLAIN SELECT example later in this section demonstrates the use of \G.

请在你的报告中包含以下信息:

Please include the following information in your report:

  1. The version number of the MySQL distribution you are using (for example, MySQL 5.7.10). You can find out which version you are running by executing mysqladmin version. The mysqladmin program can be found in the bin directory under your MySQL installation directory.

  2. The manufacturer and model of the machine on which you experience the problem.

  3. The operating system name and version. If you work with Windows, you can usually get the name and version number by double-clicking your My Computer icon and pulling down the “Help/About Windows” menu. For most Unix-like operating systems, you can get this information by executing the command uname -a.

  4. Sometimes the amount of memory (real and virtual) is relevant. If in doubt, include these values.

  5. The contents of the docs/INFO_BIN file from your MySQL installation. This file contains information about how MySQL was configured and compiled.

  6. If you are using a source distribution of the MySQL software, include the name and version number of the compiler that you used. If you have a binary distribution, include the distribution name.

  7. If the problem occurs during compilation, include the exact error messages and also a few lines of context around the offending code in the file where the error occurs.

  8. If mysqld died, you should also report the statement that caused mysqld to unexpectedly exit. You can usually get this information by running mysqld with query logging enabled, and then looking in the log after mysqld exits. See Section 7.9, “Debugging MySQL”.

  9. If a database table is related to the problem, include the output from the SHOW CREATE TABLE _db_name.tbl_name_ statement in the bug report. This is a very easy way to get the definition of any table in a database. The information helps us create a situation matching the one that you have experienced.

  10. The SQL mode in effect when the problem occurred can be significant, so please report the value of the sql_mode system variable. For stored procedure, stored function, and trigger objects, the relevant sql_mode value is the one in effect when the object was created. For a stored procedure or function, the SHOW CREATE PROCEDURE or SHOW CREATE FUNCTION statement shows the relevant SQL mode, or you can query INFORMATION_SCHEMA for the information: SELECT ROUTINE_SCHEMA, ROUTINE_NAME, SQL_MODE FROM INFORMATION_SCHEMA.ROUTINES; For triggers, you can use this statement: SELECT EVENT_OBJECT_SCHEMA, EVENT_OBJECT_TABLE, TRIGGER_NAME, SQL_MODE FROM INFORMATION_SCHEMA.TRIGGERS;

  11. For performance-related bugs or problems with SELECT statements, you should always include the output of EXPLAIN SELECT …​, and at least the number of rows that the SELECT statement produces. You should also include the output from SHOW CREATE TABLE _tbl_name_ for each table that is involved. The more information you provide about your situation, the more likely it is that someone can help you.

以下是关于一个非常好的错误报告的示例。以下语句使用 mysql 命令行工具运行。请注意使用 \G 语句终止符,以获取需要长时间输出的行,以便于阅读。 mysql> SHOW VARIABLES; mysql> SHOW COLUMNS FROM …​\G _<output from SHOW COLUMNS> mysql> EXPLAIN SELECT …​\G <output from EXPLAIN> mysql> FLUSH STATUS;mysql> SELECT …​; <A short version of the output from SELECT, including the time taken to run the query> mysql> SHOW STATUS; <output from SHOW STATUS>_

The following is an example of a very good bug report. The statements are run using the mysql command-line tool. Note the use of the \G statement terminator for statements that would otherwise provide very long output lines that are difficult to read. mysql> SHOW VARIABLES; mysql> SHOW COLUMNS FROM …​\G _<output from SHOW COLUMNS> mysql> EXPLAIN SELECT …​\G <output from EXPLAIN> mysql> FLUSH STATUS; mysql> SELECT …​; <A short version of the output from SELECT, including the time taken to run the query> mysql> SHOW STATUS; <output from SHOW STATUS>_

  1. If a bug or problem occurs while running mysqld, try to provide an input script that reproduces the anomaly. This script should include any necessary source files. The more closely the script can reproduce your situation, the better. If you can make a reproducible test case, you should upload it to be attached to the bug report.

如果您无法提供脚本,则您应该至少在您的报告中包含 mysqladmin variables extended-status processlist 的输出信息,以供了解您的系统执行方式。

If you cannot provide a script, you should at least include the output from mysqladmin variables extended-status processlist in your report to provide some information on how your system is performing.

  1. If you cannot produce a test case with only a few rows, or if the test table is too big to be included in the bug report (more than 10 rows), you should dump your tables using mysqldump and create a README file that describes your problem. Create a compressed archive of your files using tar and gzip or zip. After you initiate a bug report for our bugs database at http://bugs.mysql.com/, click the Files tab in the bug report for instructions on uploading the archive to the bugs database.

  2. If you believe that the MySQL server produces a strange result from a statement, include not only the result, but also your opinion of what the result should be, and an explanation describing the basis for your opinion.

  3. When you provide an example of the problem, it is better to use the table names, variable names, and so forth that exist in your actual situation than to come up with new names. The problem could be related to the name of a table or variable. These cases are rare, perhaps, but it is better to be safe than sorry. After all, it should be easier for you to provide an example that uses your actual situation, and it is by all means better for us. If you have data that you do not want to be visible to others in the bug report, you can upload it using the Files tab as previously described. If the information is really top secret and you do not want to show it even to us, go ahead and provide an example using other names, but please regard this as the last choice.

  4. Include all the options given to the relevant programs, if possible. For example, indicate the options that you use when you start the mysqld server, as well as the options that you use to run any MySQL client programs. The options to programs such as mysqld and mysql, and to the configure script, are often key to resolving problems and are very relevant. It is never a bad idea to include them. If your problem involves a program written in a language such as Perl or PHP, please include the language processor’s version number, as well as the version for any modules that the program uses. For example, if you have a Perl script that uses the DBI and DBD::mysql modules, include the version numbers for Perl, DBI, and DBD::mysql.

  5. If your question is related to the privilege system, please include the output of mysqladmin reload, and all the error messages you get when trying to connect. When you test your privileges, you should execute mysqladmin reload version and try to connect with the program that gives you trouble.

  6. If you have a patch for a bug, do include it. But do not assume that the patch is all we need, or that we can use it, if you do not provide some necessary information such as test cases showing the bug that your patch fixes. We might find problems with your patch or we might not understand it at all. If so, we cannot use it.

如果我们无法验证补丁的确切目的,我们就不会使用它。测试用例在这里对我们有帮助。显示补丁处理所有可能出现的情况。如果我们发现补丁不起作用的界线情况(即便罕见),它可能就毫无用处。

If we cannot verify the exact purpose of the patch, we will not use it. Test cases help us here. Show that the patch handles all the situations that may occur. If we find a borderline case (even a rare one) where the patch will not work, it may be useless.

  1. Guesses about what the bug is, why it occurs, or what it depends on are usually wrong. Even the MySQL team cannot guess such things without first using a debugger to determine the real cause of a bug.

  2. Indicate in your bug report that you have checked the reference manual and mail archive so that others know you have tried to solve the problem yourself.

  3. If your data appears corrupt or you get errors when you access a particular table, first check your tables with CHECK TABLE. If that statement reports any errors:

InnoDB 崩溃恢复机制能在服务器被杀死并重启后处理清理,所以在典型的操作中没有必要“修复”表格。如果您使用 InnoDB 表格时遇到错误信息,请重启服务器并观察问题是否仍然出现,或者错误是否仅影响到内存中的已缓存数据。如果磁盘数据已毁损,请考虑使用启用了 innodb_force_recovery 选项重启服务器,以便您可以转储受影响的表格。

The InnoDB crash recovery mechanism handles cleanup when the server is restarted after being killed, so in typical operation there is no need to “repair” tables. If you encounter an error with InnoDB tables, restart the server and see whether the problem persists, or whether the error affected only cached data in memory. If data is corrupted on disk, consider restarting with the innodb_force_recovery option enabled so that you can dump the affected tables.

对于非事务性表格,尝试使用 REPAIR TABLEmyisamchk 来修复它们。请参阅 Chapter 7, MySQL Server Administration

For non-transactional tables, try to repair them with REPAIR TABLE or with myisamchk. See Chapter 7, MySQL Server Administration.

如果您正在运行 Windows,请使用 SHOW VARIABLES LIKE 'lower_case_table_names' 语句验证 lower_case_table_names 的值。此变量影响服务器如何处理数据库和表格名称的字母大小写。对于给定值,其作用应如 Section 11.2.3, “Identifier Case Sensitivity” 中所述。

If you are running Windows, please verify the value of lower_case_table_names using the SHOW VARIABLES LIKE 'lower_case_table_names' statement. This variable affects how the server handles lettercase of database and table names. Its effect for a given value should be as described in Section 11.2.3, “Identifier Case Sensitivity”.

  1. The InnoDB crash recovery mechanism handles cleanup when the server is restarted after being killed, so in typical operation there is no need to “repair” tables. If you encounter an error with InnoDB tables, restart the server and see whether the problem persists, or whether the error affected only cached data in memory. If data is corrupted on disk, consider restarting with the innodb_force_recovery option enabled so that you can dump the affected tables.

  2. For non-transactional tables, try to repair them with REPAIR TABLE or with myisamchk. See Chapter 7, MySQL Server Administration.

  3. If you often get corrupted tables, you should try to find out when and why this happens. In this case, the error log in the MySQL data directory may contain some information about what happened. (This is the file with the .err suffix in the name.) See Section 7.4.2, “The Error Log”. Please include any relevant information from this file in your bug report. Normally mysqld should never corrupt a table if nothing killed it in the middle of an update. If you can find the cause of mysqld dying, it is much easier for us to provide you with a fix for the problem. See Section B.3.1, “How to Determine What Is Causing a Problem”.

  4. If possible, download and install the most recent version of MySQL Server and check whether it solves your problem. All versions of the MySQL software are thoroughly tested and should work without problems. We believe in making everything as backward-compatible as possible, and you should be able to switch MySQL versions without difficulty. See Section 2.1.2, “Which MySQL Version and Distribution to Install”.