<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ru Servers Reference Blog &#187; MYSQL</title>
	<atom:link href="http://blog.server.ruservers.com/category/server/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.server.ruservers.com</link>
	<description>Server Maintenance Guide</description>
	<lastBuildDate>Tue, 27 Jul 2010 12:14:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>mysqlcheck &#8212; A Table Maintenance and Repair Program</title>
		<link>http://blog.server.ruservers.com/2009/01/mysqlcheck-a-table-maintenance-and-repair-program/</link>
		<comments>http://blog.server.ruservers.com/2009/01/mysqlcheck-a-table-maintenance-and-repair-program/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 09:42:34 +0000</pubDate>
		<dc:creator>Ru Servers</dc:creator>
				<category><![CDATA[MYSQL]]></category>

		<guid isPermaLink="false">http://blog.server.ruservers.com/2009/01/mysqlcheck-a-table-maintenance-and-repair-program/</guid>
		<description><![CDATA[&#160; Source:http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html &#160; The mysqlcheck client checks, repairs, optimizes, and analyzes tables. mysqlcheck is available as of MySQL 3.23.38. mysqlcheck is similar in function to myisamchk, but works differently. The main operational difference is that mysqlcheck must be used when the mysqld server is running, whereas myisamchk should be used when it is not. The [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>Source:<a title="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html" href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html">http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html</a></p>
<p>&#160;</p>
<h5>The <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> client checks, repairs, optimizes, and analyzes tables. <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> is available as of MySQL 3.23.38. </h5>
<p><a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> is similar in function to <a href="http://dev.mysql.com/doc/refman/4.1/en/myisamchk.html"><strong>myisamchk</strong></a>, but works differently. The main operational difference is that <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> must be used when the <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqld.html"><strong>mysqld</strong></a> server is running, whereas <a href="http://dev.mysql.com/doc/refman/4.1/en/myisamchk.html"><strong>myisamchk</strong></a> should be used when it is not. The benefit of using <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> is that you do not have to stop the server to check or repair your tables. </p>
<p><a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> uses the SQL statements <a href="http://dev.mysql.com/doc/refman/4.1/en/check-table.html"><code>CHECK TABLE</code></a>, <a href="http://dev.mysql.com/doc/refman/4.1/en/repair-table.html"><code>REPAIR TABLE</code></a>, <a href="http://dev.mysql.com/doc/refman/4.1/en/analyze-table.html"><code>ANALYZE TABLE</code></a>, and <a href="http://dev.mysql.com/doc/refman/4.1/en/optimize-table.html"><code>OPTIMIZE TABLE</code></a> in a convenient way for the user. It determines which statements to use for the operation you want to perform, and then sends the statements to the server to be executed. For details about which storage engines each statement works with, see the descriptions for those statements in <a href="http://dev.mysql.com/doc/refman/4.1/en/sql-syntax.html">Chapter 12, <i>SQL Statement Syntax</i></a>. </p>
<p>The <code>MyISAM</code> storage engine supports all four statements, so <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> can be used to perform all four operations on <code>MyISAM</code> tables. Other storage engines do not necessarily support all operations. In such cases, an error message is displayed. For example, if <code>test.t</code> is a <code>MEMORY</code> table, an attempt to check it produces this result: </p>
<pre>shell&gt; <strong><code>mysqlcheck test t</code></strong>
test.t
note     : The storage engine for the table doesn't support check</pre>
<h5>Caution</h5>
<p>It is best to make a backup of a table before performing a table repair operation; under some circumstances the operation might cause data loss. Possible causes include but are not limited to filesystem errors. </p>
<p>There are three general ways to invoke <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a>: </p>
<pre>shell&gt; <strong><code>mysqlcheck [<em><code>options</code></em>] <em><code>db_name</code></em> [<em><code>tables</code></em>]</code></strong>
shell&gt; <strong><code>mysqlcheck [<em><code>options</code></em>] --databases <em><code>db_name1</code></em> [<em><code>db_name2</code></em> <em><code>db_name3</code></em>...]</code></strong>
shell&gt; <strong><code>mysqlcheck [<em><code>options</code></em>] --all-databases</code></strong></pre>
<p>If you do not name any tables following <em><code>db_name</code></em> or if you use the <code>--databases</code> or <code>--all-databases</code> option, entire databases are checked. </p>
<p><a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> has a special feature compared to other client programs. The default behavior of checking tables (<code>--check</code>) can be changed by renaming the binary. If you want to have a tool that repairs tables by default, you should just make a copy of <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> named <strong>mysqlrepair</strong>, or make a symbolic link to <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> named <strong>mysqlrepair</strong>. If you invoke <strong>mysqlrepair</strong>, it repairs tables. </p>
<p>The following names can be used to change <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> default behavior: </p>
<p><strong>mysqlrepair</strong></p>
<p>The default option is <code>--repair</code></p>
<p><strong>mysqlanalyze</strong></p>
<p>The default option is <code>--analyze</code></p>
<p><strong>mysqloptimize</strong></p>
<p>The default option is <code>--optimize</code></p>
<p><a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> supports the following options: </p>
<ul>
<li>
<p><a name="option_mysqlcheck_help"></a><a name="id2561930"></a><a name="id2561943"></a><code>--help</code>, <code>-?</code></p>
<p>Display a help message and exit. </p>
</li>
<li>
<p><a name="option_mysqlcheck_all-databases"></a><a name="id2561975"></a><a name="id2561988"></a><code>--all-databases</code>, <code>-A</code></p>
<p>Check all tables in all databases. This is the same as using the <code>--databases</code> option and naming all the databases on the command line. </p>
</li>
<li>
<p><a name="option_mysqlcheck_all-in-1"></a><a name="id2562026"></a><a name="id2562039"></a><code>--all-in-1</code>, <code>-1</code></p>
<p>Instead of issuing a statement for each table, execute a single statement for each database that names all the tables from that database to be processed. </p>
</li>
<li>
<p><a name="option_mysqlcheck_analyze"></a><a name="id2562073"></a><a name="id2562086"></a><code>--analyze</code>, <code>-a</code></p>
<p>Analyze the tables. </p>
<p><b>MySQL Enterprise. </b> For expert advice on optimizing tables, subscribe to the MySQL Enterprise Monitor. For more information, see <a href="http://www.mysql.com/products/enterprise/advisors.html">http://www.mysql.com/products/enterprise/advisors.html</a>. </p>
</li>
<li>
<p><a name="option_mysqlcheck_auto-repair"></a><a name="id2562139"></a><a name="id2562151"></a><code>--auto-repair</code></p>
<p>If a checked table is corrupted, automatically fix it. Any necessary repairs are done after all tables have been checked. </p>
</li>
<li>
<p><a name="option_mysqlcheck_character-sets-dir"></a><a name="id2562183"></a><a name="id2562195"></a><code>--character-sets-dir=<em><code>path</code></em></code></p>
<p>The directory where character sets are installed. See <a href="http://dev.mysql.com/doc/refman/4.1/en/charset-configuration.html">Section 9.2, “The Character Set Used for Data and Sorting”</a>. </p>
</li>
<li>
<p><a name="option_mysqlcheck_check"></a><a name="id2562233"></a><a name="id2562245"></a><code>--check</code>, <code>-c</code></p>
<p>Check the tables for errors. This is the default operation. </p>
</li>
<li>
<p><a name="option_mysqlcheck_check-only-changed"></a><a name="id2562278"></a><a name="id2562291"></a><code>--check-only-changed</code>, <code>-C</code></p>
<p>Check only tables that have changed since the last check or that have not been closed properly. </p>
</li>
<li>
<p><a name="option_mysqlcheck_compress"></a><a name="id2562325"></a><a name="id2562338"></a><code>--compress</code></p>
<p>Compress all information sent between the client and the server if both support compression. </p>
</li>
<li>
<p><a name="option_mysqlcheck_databases"></a><a name="id2562368"></a><a name="id2562381"></a><code>--databases</code>, <code>-B</code></p>
<p>Process all tables in the named databases. Normally, <a href="http://dev.mysql.com/doc/refman/4.1/en/mysqlcheck.html"><strong>mysqlcheck</strong></a> treats the first name argument on the command line as a database name and following names as table names. With this option, it treats all name arguments as database names. </p>
</li>
<li>
<p><a name="option_mysqlcheck_debug"></a><a name="id2562424"></a><a name="id2562436"></a><code>--debug[=<em><code>debug_options</code></em>]</code>, <code>-# [<em><code>debug_options</code></em>]</code></p>
<p>Write a debugging log. A typical <em><code>debug_options</code></em> string is often <code>'d:t:o,<em><code>file_name</code></em>'</code>. </p>
</li>
<li>
<p><a name="option_mysqlcheck_default-character-set"></a><a name="id2562491"></a><a name="id2562504"></a><code>--default-character-set=<em><code>charset_name</code></em></code></p>
<p>Use <em><code>charset_name</code></em> as the default character set. See <a href="http://dev.mysql.com/doc/refman/4.1/en/charset-configuration.html">Section 9.2, “The Character Set Used for Data and Sorting”</a>. </p>
</li>
<li>
<p><a name="option_mysqlcheck_extended"></a><a name="id2562545"></a><a name="id2562558"></a><code>--extended</code>, <code>-e</code></p>
<p>If you are using this option to check tables, it ensures that they are 100% consistent but takes a long time. </p>
<p>If you are using this option to repair tables, it runs an extended repair that may not only take a long time to execute, but may produce a lot of garbage rows also! </p>
</li>
<li>
<p><a name="option_mysqlcheck_fast"></a><a name="id2562598"></a><a name="id2562611"></a><code>--fast</code>, <code>-F</code></p>
<p>Check only tables that have not been closed properly. </p>
</li>
<li>
<p><a name="option_mysqlcheck_force"></a><a name="id2562643"></a><a name="id2562656"></a><code>--force</code>, <code>-f</code></p>
<p>Continue even if an SQL error occurs. </p>
</li>
<li>
<p><a name="option_mysqlcheck_host"></a><a name="id2562688"></a><a name="id2562701"></a><code>--host=<em><code>host_name</code></em></code>, <code>-h <em><code>host_name</code></em></code></p>
<p>Connect to the MySQL server on the given host. </p>
</li>
<li>
<p><a name="option_mysqlcheck_medium-check"></a><a name="id2562739"></a><a name="id2562751"></a><code>--medium-check</code>, <code>-m</code></p>
<p>Do a check that is faster than an <code>--extended</code> operation. This finds only 99.99% of all errors, which should be good enough in most cases. </p>
</li>
<li>
<p><a name="option_mysqlcheck_optimized"></a><a name="id2562790"></a><a name="id2562802"></a><code>--optimize</code>, <code>-o</code></p>
<p>Optimize the tables. </p>
</li>
<li>
<p><a name="option_mysqlcheck_password"></a><a name="id2562834"></a><a name="id2562847"></a><code>--password[=<em><code>password</code></em>]</code>, <code>-p[<em><code>password</code></em>]</code></p>
<p>The password to use when connecting to the server. If you use the short option form (<code>-p</code>), you <em>cannot</em> have a space between the option and the password. If you omit the <em><code>password</code></em> value following the <code>--password</code> or <code>-p</code> option on the command line, you are prompted for one. </p>
<p>Specifying a password on the command line should be considered insecure. See <a href="http://dev.mysql.com/doc/refman/4.1/en/password-security.html">Section 5.6.6, “Keeping Passwords Secure”</a>. </p>
</li>
<li>
<p><a name="option_mysqlcheck_pipe"></a><a name="id2562919"></a><a name="id2562931"></a><code>--pipe</code>, <code>-W</code></p>
<p>On Windows, connect to the server via a named pipe. This option applies only for connections to a local server, and only if the server supports named-pipe connections. </p>
</li>
<li>
<p><a name="option_mysqlcheck_port"></a><a name="id2562966"></a><a name="id2562979"></a><code>--port=<em><code>port_num</code></em></code>, <code>-P <em><code>port_num</code></em></code></p>
<p>The TCP/IP port number to use for the connection. </p>
</li>
<li>
<p><a name="option_mysqlcheck_protocol"></a><a name="id2563016"></a><a name="id2563029"></a><code>--protocol={TCP|SOCKET|PIPE|MEMORY}</code></p>
<p>The connection protocol to use for connecting to the server. It is useful when the other connection parameters normally would cause a protocol to be used other than the one you want. For details on the allowable values, see <a href="http://dev.mysql.com/doc/refman/4.1/en/connecting.html">Section 4.2.2, “Connecting to the MySQL Server”</a>. This option was added in MySQL 4.1. </p>
</li>
<li>
<p><a name="option_mysqlcheck_quick"></a><a name="id2563068"></a><a name="id2563081"></a><code>--quick</code>, <code>-q</code></p>
<p>If you are using this option to check tables, it prevents the check from scanning the rows to check for incorrect links. This is the fastest check method. </p>
<p>If you are using this option to repair tables, it tries to repair only the index tree. This is the fastest repair method. </p>
</li>
<li>
<p><a name="option_mysqlcheck_repair"></a><a name="id2563122"></a><a name="id2563134"></a><code>--repair</code>, <code>-r</code></p>
<p>Perform a repair that can fix almost anything except unique keys that are not unique. </p>
</li>
<li>
<p><a name="option_mysqlcheck_silent"></a><a name="id2563168"></a><a name="id2563180"></a><code>--silent</code>, <code>-s</code></p>
<p>Silent mode. Print only error messages. </p>
</li>
<li>
<p><a name="option_mysqlcheck_socket"></a><a name="id2563213"></a><a name="id2563225"></a><code>--socket=<em><code>path</code></em></code>, <code>-S <em><code>path</code></em></code></p>
<p>For connections to <code>localhost</code>, the Unix socket file to use, or, on Windows, the name of the named pipe to use. </p>
</li>
<li>
<p><a name="option_mysqlcheck_ssl"></a><a name="id2563270"></a><a name="id2563283"></a><code>--ssl*</code></p>
<p>Options that begin with <code>--ssl</code> specify whether to connect to the server via SSL and indicate where to find SSL keys and certificates. See <a href="http://dev.mysql.com/doc/refman/4.1/en/ssl-options.html">Section 5.6.7.3, “SSL Command Options”</a>. </p>
</li>
<li>
<p><a name="option_mysqlcheck_tables"></a><a name="id2563322"></a><a name="id2563335"></a><code>--tables</code></p>
<p>Overrides the <code>--databases</code> or <code>-B</code> option. All name arguments following the option are regarded as table names. </p>
</li>
<li>
<p><a name="option_mysqlcheck_use-frm"></a><a name="id2563372"></a><a name="id2563385"></a><code>--use-frm</code></p>
<p>For repair operations on <code>MyISAM</code> tables, get the table structure from the <code>.frm</code> file so that the table can be repaired even if the <code>.MYI</code> header is corrupted. This option was added in MySQL 4.0.5. </p>
</li>
<li>
<p><a name="option_mysqlcheck_user"></a><a name="id2563435"></a><a name="id2563447"></a><code>--user=<em><code>user_name</code></em></code>, <code>-u <em><code>user_name</code></em></code></p>
<p>The MySQL user name to use when connecting to the server. </p>
</li>
<li>
<p><a name="option_mysqlcheck_verbose"></a><a name="id2563485"></a><a name="id2563498"></a><code>--verbose</code>, <code>-v</code></p>
<p>Verbose mode. Print information about the various stages of program operation. </p>
</li>
<li>
<p><a name="option_mysqlcheck_version"></a><a name="id2563531"></a><a name="id2563544"></a><code>--version</code>, <code>-V</code></p>
<p>Display version information and exit. </p>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.server.ruservers.com/2009/01/mysqlcheck-a-table-maintenance-and-repair-program/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Forcing InnoDB Recovery</title>
		<link>http://blog.server.ruservers.com/2009/01/forcing-innodb-recovery/</link>
		<comments>http://blog.server.ruservers.com/2009/01/forcing-innodb-recovery/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 09:36:05 +0000</pubDate>
		<dc:creator>Ru Servers</dc:creator>
				<category><![CDATA[MYSQL]]></category>

		<guid isPermaLink="false">http://blog.server.ruservers.com/2009/01/forcing-innodb-recovery/</guid>
		<description><![CDATA[&#160; Source: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html&#160; &#160; If there is database page corruption, you may want to dump your tables from the database with SELECT INTO ... OUTFILE. Usually, most of the data obtained in this way is intact. However, it is possible that the corruption might cause SELECT * FROM tbl_name statements or InnoDB background operations to [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>Source: <a title="http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html" href="http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html">http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html</a>&#160;</p>
<p>&#160;</p>
<p>If there is database page corruption, you may want to dump your tables from the database with <code>SELECT INTO ... OUTFILE</code>. Usually, most of the data obtained in this way is intact. However, it is possible that the corruption might cause <code>SELECT * FROM <em><code>tbl_name</code></em></code> statements or <code>InnoDB</code> background operations to crash or assert, or even cause <code>InnoDB</code> roll-forward recovery to crash. In such cases, you can use the <a href="http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_force_recovery"><code>innodb_force_recovery</code></a> option to force the <code>InnoDB</code> storage engine to start up while preventing background operations from running, so that you are able to dump your tables. For example, you can add the following line to the <code>[mysqld]</code> section of your option file before restarting the server: </p>
<pre>[mysqld]
innodb_force_recovery = 4</pre>
<p><a href="http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_force_recovery"><code>innodb_force_recovery</code></a> is 0 by default (normal startup without forced recovery) The allowable non-zero values for <a href="http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_force_recovery"><code>innodb_force_recovery</code></a> follow. A larger number includes all precautions of smaller numbers. If you are able to dump your tables with an option value of at most 4, then you are relatively safe that only some data on corrupt individual pages is lost. A value of 6 is more drastic because database pages are left in an obsolete state, which in turn may introduce more corruption into B-trees and other database structures. </p>
<ul>
<li>
<p><code>1</code> (<code>SRV_FORCE_IGNORE_CORRUPT</code>) </p>
<p>Let the server run even if it detects a corrupt page. Try to make <code>SELECT * FROM <em><code>tbl_name</code></em></code> jump over corrupt index records and pages, which helps in dumping tables. </p>
</li>
<li>
<p><code>2</code> (<code>SRV_FORCE_NO_BACKGROUND</code>) </p>
<p>Prevent the main thread from running. If a crash would occur during the purge operation, this recovery value prevents it. </p>
</li>
<li>
<p><code>3</code> (<code>SRV_FORCE_NO_TRX_UNDO</code>) </p>
<p>Do not run transaction rollbacks after recovery. </p>
</li>
<li>
<p><code>4</code> (<code>SRV_FORCE_NO_IBUF_MERGE</code>) </p>
<p>Prevent insert buffer merge operations. If they would cause a crash, do not do them. Do not calculate table statistics. </p>
</li>
<li>
<p><code>5</code> (<code>SRV_FORCE_NO_UNDO_LOG_SCAN</code>) </p>
<p>Do not look at undo logs when starting the database: <code>InnoDB</code> treats even incomplete transactions as committed. </p>
</li>
<li>
<p><code>6</code> (<code>SRV_FORCE_NO_LOG_REDO</code>) </p>
<p>Do not do the log roll-forward in connection with recovery. </p>
</li>
</ul>
<p><em>The database must not otherwise be used with any non-zero value of <a href="http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_force_recovery"><code>innodb_force_recovery</code></a></em>. As a safety measure, <code>InnoDB</code> prevents users from performing <a href="http://dev.mysql.com/doc/refman/5.1/en/insert.html"><code>INSERT</code></a>, <a href="http://dev.mysql.com/doc/refman/5.1/en/update.html"><code>UPDATE</code></a>, or <a href="http://dev.mysql.com/doc/refman/5.1/en/delete.html"><code>DELETE</code></a> operations when <a href="http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_force_recovery"><code>innodb_force_recovery</code></a> is greater than 0. </p>
<p>You can <a href="http://dev.mysql.com/doc/refman/5.1/en/select.html"><code>SELECT</code></a> from tables to dump them, or <code>DROP</code> or <code>CREATE</code> tables even if forced recovery is used. If you know that a given table is causing a crash on rollback, you can drop it. You can also use this to stop a runaway rollback caused by a failing mass import or <a href="http://dev.mysql.com/doc/refman/5.1/en/alter-table.html"><code>ALTER TABLE</code></a>. You can kill the <a href="http://dev.mysql.com/doc/refman/5.1/en/mysqld.html"><strong>mysqld</strong></a> process and set <a href="http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_force_recovery"><code>innodb_force_recovery</code></a> to <code>3</code> to bring the database up without the rollback, then <code>DROP</code> the table that is causing the runaway rollback. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.server.ruservers.com/2009/01/forcing-innodb-recovery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MYSQL &#8211; How to Repair Tables</title>
		<link>http://blog.server.ruservers.com/2009/01/mysql-how-to-repair-tables/</link>
		<comments>http://blog.server.ruservers.com/2009/01/mysql-how-to-repair-tables/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 19:34:27 +0000</pubDate>
		<dc:creator>Ru Servers</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[MYSQL]]></category>
		<category><![CDATA[Repair]]></category>

		<guid isPermaLink="false">http://blog.server.ruservers.com/2009/01/mysql-how-to-repair-tables/</guid>
		<description><![CDATA[&#160; Source: http://dev.mysql.com/doc/refman/5.1/en/repair.html &#160; The discussion in this section describes how to use myisamchk on MyISAM tables (extensions .MYI and .MYD). You can also (and should, if possible) use the CHECK TABLE and REPAIR TABLE statements to check and repair MyISAM tables. See Section 12.5.2.3, “CHECK TABLE Syntax”, and Section 12.5.2.6, “REPAIR TABLE Syntax”. Symptoms [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>Source: <a title="http://dev.mysql.com/doc/refman/5.1/en/repair.html" href="http://dev.mysql.com/doc/refman/5.1/en/repair.html">http://dev.mysql.com/doc/refman/5.1/en/repair.html</a></p>
<p>&#160;</p>
<p>The discussion in this section describes how to use <a href="http://dev.mysql.com/doc/refman/5.1/en/myisamchk.html"><strong>myisamchk</strong></a> on <code>MyISAM</code> tables (extensions <code>.MYI</code> and <code>.MYD</code>). </p>
<p>You can also (and should, if possible) use the <a href="http://dev.mysql.com/doc/refman/5.1/en/check-table.html"><code>CHECK TABLE</code></a> and <a href="http://dev.mysql.com/doc/refman/5.1/en/repair-table.html"><code>REPAIR TABLE</code></a> statements to check and repair <code>MyISAM</code> tables. See <a href="http://dev.mysql.com/doc/refman/5.1/en/check-table.html">Section 12.5.2.3, “<code>CHECK TABLE</code> Syntax”</a>, and <a href="http://dev.mysql.com/doc/refman/5.1/en/repair-table.html">Section 12.5.2.6, “<code>REPAIR TABLE</code> Syntax”</a>. </p>
<p>Symptoms of corrupted tables include queries that abort unexpectedly and observable errors such as these: </p>
<ul>
<li>
<p><code><em><code>tbl_name</code></em>.frm</code> is locked against change </p>
</li>
<li>
<p>Can&#8217;t find file <code><em><code>tbl_name</code></em>.MYI</code> (Errcode: <em><code>nnn</code></em>) </p>
</li>
<li>
<p>Unexpected end of file </p>
</li>
<li>
<p>Record file is crashed </p>
</li>
<li>
<p>Got error <em><code>nnn</code></em> from table handler </p>
</li>
</ul>
<p>To get more information about the error, run <a href="http://dev.mysql.com/doc/refman/5.1/en/perror.html"><strong>perror</strong></a> <em><code>nnn</code></em>, where <em><code>nnn</code></em> is the error number. The following example shows how to use <a href="http://dev.mysql.com/doc/refman/5.1/en/perror.html"><strong>perror</strong></a> to find the meanings for the most common error numbers that indicate a problem with a table: </p>
<pre>shell&gt; <strong><code>perror 126 127 132 134 135 136 141 144 145</code></strong>
MySQL error code 126 = Index file is crashed
MySQL error code 127 = Record-file is crashed
MySQL error code 132 = Old database file
MySQL error code 134 = Record was already deleted (or record file crashed)
MySQL error code 135 = No more room in record file
MySQL error code 136 = No more room in index file
MySQL error code 141 = Duplicate unique key or constraint on write or update
MySQL error code 144 = Table is crashed and last repair failed
MySQL error code 145 = Table was marked as crashed and should be repaired</pre>
<p>Note that error 135 (no more room in record file) and error 136 (no more room in index file) are not errors that can be fixed by a simple repair. In this case, you must use <a href="http://dev.mysql.com/doc/refman/5.1/en/alter-table.html"><code>ALTER TABLE</code></a> to increase the <code>MAX_ROWS</code> and <code>AVG_ROW_LENGTH</code> table option values: </p>
<pre>ALTER TABLE <em><code>tbl_name</code></em> MAX_ROWS=<em><code>xxx</code></em> AVG_ROW_LENGTH=<em><code>yyy</code></em>;</pre>
<p>If you do not know the current table option values, use <a href="http://dev.mysql.com/doc/refman/5.1/en/show-create-table.html"><code>SHOW CREATE TABLE</code></a>. </p>
<p>For the other errors, you must repair your tables. <a href="http://dev.mysql.com/doc/refman/5.1/en/myisamchk.html"><strong>myisamchk</strong></a> can usually detect and fix most problems that occur. </p>
<p>The repair process involves up to four stages, described here. Before you begin, you should change location to the database directory and check the permissions of the table files. On Unix, make sure that they are readable by the user that <a href="http://dev.mysql.com/doc/refman/5.1/en/mysqld.html"><strong>mysqld</strong></a> runs as (and to you, because you need to access the files you are checking). If it turns out you need to modify files, they must also be writable by you. </p>
<p>This section is for the cases where a table check fails (such as those described in <a href="http://dev.mysql.com/doc/refman/5.1/en/check.html">Section 6.4.2, “How to Check <code>MyISAM</code> Tables for Errors”</a>), or you want to use the extended features that <a href="http://dev.mysql.com/doc/refman/5.1/en/myisamchk.html"><strong>myisamchk</strong></a> provides. </p>
<p>The options that you can use for table maintenance with <a href="http://dev.mysql.com/doc/refman/5.1/en/myisamchk.html"><strong>myisamchk</strong></a> are described in <a href="http://dev.mysql.com/doc/refman/5.1/en/myisamchk.html">Section 4.6.3, “<strong>myisamchk</strong> — MyISAM Table-Maintenance Utility”</a>. </p>
<p>If you are going to repair a table from the command line, you must first stop the <a href="http://dev.mysql.com/doc/refman/5.1/en/mysqld.html"><strong>mysqld</strong></a> server. Note that when you do <a href="http://dev.mysql.com/doc/refman/5.1/en/mysqladmin.html"><strong>mysqladmin shutdown</strong></a> on a remote server, the <a href="http://dev.mysql.com/doc/refman/5.1/en/mysqld.html"><strong>mysqld</strong></a> server is still alive for a while after <a href="http://dev.mysql.com/doc/refman/5.1/en/mysqladmin.html"><strong>mysqladmin</strong></a> returns, until all statement-processing has stopped and all index changes have been flushed to disk. </p>
<p><strong>Stage 1: Checking your tables</strong></p>
<p>Run <a href="http://dev.mysql.com/doc/refman/5.1/en/myisamchk.html"><strong>myisamchk *.MYI</strong></a> or <a href="http://dev.mysql.com/doc/refman/5.1/en/myisamchk.html"><strong>myisamchk -e *.MYI</strong></a> if you have more time. Use the <code>-s</code> (silent) option to suppress unnecessary information. </p>
<p>If the <a href="http://dev.mysql.com/doc/refman/5.1/en/mysqld.html"><strong>mysqld</strong></a> server is stopped, you should use the <code>--update-state</code> option to tell <a href="http://dev.mysql.com/doc/refman/5.1/en/myisamchk.html"><strong>myisamchk</strong></a> to mark the table as “checked.” </p>
<p>You have to repair only those tables for which <a href="http://dev.mysql.com/doc/refman/5.1/en/myisamchk.html"><strong>myisamchk</strong></a> announces an error. For such tables, proceed to Stage 2. </p>
<p>If you get unexpected errors when checking (such as <code>out of memory</code> errors), or if <a href="http://dev.mysql.com/doc/refman/5.1/en/myisamchk.html"><strong>myisamchk</strong></a> crashes, go to Stage 3. </p>
<p><strong>Stage 2: Easy safe repair</strong></p>
<p>First, try <a href="http://dev.mysql.com/doc/refman/5.1/en/myisamchk.html"><strong>myisamchk -r -q <em><code>tbl_name</code></em></strong></a> (<code>-r -q</code> means “quick recovery mode”). This attempts to repair the index file without touching the data file. If the data file contains everything that it should and the delete links point at the correct locations within the data file, this should work, and the table is fixed. Start repairing the next table. Otherwise, use the following procedure: </p>
<ol>
<li>
<p>Make a backup of the data file before continuing. </p>
</li>
<li>
<p>Use <a href="http://dev.mysql.com/doc/refman/5.1/en/myisamchk.html"><strong>myisamchk -r <em><code>tbl_name</code></em></strong></a> (<code>-r</code> means “recovery mode”). This removes incorrect rows and deleted rows from the data file and reconstructs the index file. </p>
</li>
<li>
<p>If the preceding step fails, use <a href="http://dev.mysql.com/doc/refman/5.1/en/myisamchk.html"><strong>myisamchk &#8211;safe-recover <em><code>tbl_name</code></em></strong></a>. Safe recovery mode uses an old recovery method that handles a few cases that regular recovery mode does not (but is slower). </p>
</li>
</ol>
<h5>Note</h5>
<p>If you want a repair operation to go much faster, you should set the values of the <a href="http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_sort_buffer_size"><code>sort_buffer_size</code></a> and <a href="http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_key_buffer_size"><code>key_buffer_size</code></a> variables each to about 25% of your available memory when running <a href="http://dev.mysql.com/doc/refman/5.1/en/myisamchk.html"><strong>myisamchk</strong></a>. </p>
<p>If you get unexpected errors when repairing (such as <code>out of memory</code> errors), or if <a href="http://dev.mysql.com/doc/refman/5.1/en/myisamchk.html"><strong>myisamchk</strong></a> crashes, go to Stage 3. </p>
<p><strong>Stage 3: Difficult repair</strong></p>
<p>You should reach this stage only if the first 16KB block in the index file is destroyed or contains incorrect information, or if the index file is missing. In this case, it is necessary to create a new index file. Do so as follows: </p>
<ol>
<li>
<p>Move the data file to a safe place. </p>
</li>
<li>
<p>Use the table description file to create new (empty) data and index files: </p>
<pre>shell&gt; <strong><code>mysql <em><code>db_name</code></em></code></strong>
mysql&gt; <strong><code>SET autocommit=1;</code></strong>
mysql&gt; <strong><code>TRUNCATE TABLE <em><code>tbl_name</code></em>;</code></strong>
mysql&gt; <strong><code>quit</code></strong></pre>
</li>
<li>
<p>Copy the old data file back onto the newly created data file. (Do not just move the old file back onto the new file. You want to retain a copy in case something goes wrong.) </p>
</li>
</ol>
<h5>Important</h5>
<p>If you are using replication, you should stop it prior to performing the above procedure, since it involves filesystem operations, and these are not logged by MySQL. </p>
<p>Go back to Stage 2. <a href="http://dev.mysql.com/doc/refman/5.1/en/myisamchk.html"><strong>myisamchk -r -q</strong></a> should work. (This should not be an endless loop.) </p>
<p>You can also use the <code>REPAIR TABLE <em><code>tbl_name</code></em> USE_FRM</code> SQL statement, which performs the whole procedure automatically. There is also no possibility of unwanted interaction between a utility and the server, because the server does all the work when you use <a href="http://dev.mysql.com/doc/refman/5.1/en/repair-table.html"><code>REPAIR TABLE</code></a>. See <a href="http://dev.mysql.com/doc/refman/5.1/en/repair-table.html">Section 12.5.2.6, “<code>REPAIR TABLE</code> Syntax”</a>. </p>
<p><strong>Stage 4: Very difficult repair</strong></p>
<p>You should reach this stage only if the <code>.frm</code> description file has also crashed. That should never happen, because the description file is not changed after the table is created: </p>
<ol>
<li>
<p>Restore the description file from a backup and go back to Stage 3. You can also restore the index file and go back to Stage 2. In the latter case, you should start with <a href="http://dev.mysql.com/doc/refman/5.1/en/myisamchk.html"><strong>myisamchk -r</strong></a>. </p>
</li>
<li>
<p>If you do not have a backup but know exactly how the table was created, create a copy of the table in another database. Remove the new data file, and then move the <code>.frm</code> description and <code>.MYI</code> index files from the other database to your crashed database. This gives you new description and index files, but leaves the <code>.MYD</code> data file alone. Go back to Stage 2 and attempt to reconstruct the index file. </p>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.server.ruservers.com/2009/01/mysql-how-to-repair-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrading to MySQL 5.1.x on cPanel</title>
		<link>http://blog.server.ruservers.com/2009/01/upgrading-to-mysql-51x-on-cpanel/</link>
		<comments>http://blog.server.ruservers.com/2009/01/upgrading-to-mysql-51x-on-cpanel/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 14:27:56 +0000</pubDate>
		<dc:creator>Ru Servers</dc:creator>
				<category><![CDATA[Cpanel]]></category>
		<category><![CDATA[MYSQL]]></category>
		<category><![CDATA[Upgrade]]></category>

		<guid isPermaLink="false">http://blog.server.ruservers.com/2009/01/upgrading-to-mysql-51x-on-cpanel/</guid>
		<description><![CDATA[&#160; Source: http://www.v-nessa.net/2007/07/20/upgrading-to-mysql-5120-on-cpanel&#160; &#160; If you have server that run on cPanel, you’ll probably know how big of a Nazi it is in regards to the MySQL versions it can run. We just got this new line of servers at work and one of them I was pretty heartset on installing MySQL 5.1, mainly because [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>Source: <a title="http://www.v-nessa.net/2007/07/20/upgrading-to-mysql-5120-on-cpanel" href="http://www.v-nessa.net/2007/07/20/upgrading-to-mysql-5120-on-cpanel">http://www.v-nessa.net/2007/07/20/upgrading-to-mysql-5120-on-cpanel</a>&#160;</p>
<p>&#160;</p>
<p>If you have server that run on cPanel, you’ll probably know how big of a Nazi it is in regards to the MySQL versions it can run. We just got this new line of servers at work and one of them I was pretty heartset on installing MySQL 5.1, mainly because of its loadable plugin features where you can install a plugin or module without having to recompile the whole damn thing. Upgrading to 5.1 is easy, you just have to follow the right steps.</p>
<p>First, I would recommend upgrading to cPanel 11 or EDGE, which should have support for compiling Apache with non-supported versions of MySQL. On this server, I’m currently running 11 on the bleeding edge build. Also, it’s a splendid idea to dump all your databases before upgrading.   <br />Note that these instructions mention MySQL 5.1.20-beta because that’s the latest release available at the time of my writing….but you can essentially follow this guide for any version of MySQL!</p>
<p>1. Copy the MySQL libraries from the server into a temporary location:   <br /><code>     <br />mkdir /root/sqllibs      <br />cp /usr/lib/libmysqlclient.* /root/sqllibs</code></p>
<p>2. Find any installed MySQL packages:   <br /><code>rpm -qa | grep -i mysql-</code></p>
<p>This should present a list of installed rpm’s…remove them with<strong> rpm -e</strong> ,but note that some may need to be removed before others. Some people also would remove the <strong>/var/lib/mysql </strong>directory, but you can leave that there.</p>
<p>3. Download and install the MySQL 5.1.x packages:</p>
<p>Hop on over to <a href="http://dev.mysql.com/downloads/mysql/5.1.html#linux-x86-32bit-rpms">http://dev.mysql.com/downloads/mysql/5.1.html#linux-x86-32bit-rpms</a> and download the 5.1 RPM’s and install them:    <br /><code>rpm -i MySQL-client-5.1.20-0.glibc23.i386.rpm     <br />rpm -i MySQL-devel-5.1.20-0.glibc23.i386.rpm      <br />rpm -i MySQL-embedded-5.1.20-0.glibc23.i386.rpm      <br />rpm -i MySQL-test-5.1.20-0.glibc23.i386.rpm      <br />rpm -i MySQL-server-5.1.20-0.glibc23.i386.rpm</code></p>
<p>4. Prepare cPanel</p>
<p>You’ll want to make sure that cPanel’s updates don’t reset the MySQL version, so you need to run the following commands to force cPanel to skip MySQL updates:   <br /><code>touch /etc/mysqldisable     <br />touch /etc/mysqlupdisable</code></p>
<p>Now edit <strong>/var/cpanel/cpanel.config </strong>and change the MySQL version to<strong> 5.1</strong></p>
<p>Create the symlink:   <br /><code>ln -s /var/lib/mysql/mysql.sock /tmp</code></p>
<p>Also, verify that the MySQL version is correct by running <strong>mysql -V </strong></p>
<blockquote><p>root@vps [~]# mysql -V     <br />mysql Ver 14.13 Distrib 5.1.20-beta, for pc-linux-gnu (i686) using readline 5.0</p>
</blockquote>
<p>5. Set up MySQL</p>
<p>MySQL should have already been started at this point, so you can attempt to log in as root using <strong>mysql -u root . </strong>If you are able to log in on the first try, great. If not, you’ll need to reset the MySQL password:    <br /><code>pico /etc/my.cnf</code></p>
<p>Add this line, and restart MySQL   <br /><code><strong>skip-grant-tables</strong></code>    <br /><code>service mysql restart</code></p>
<p>Now log into MySQL root and set the password:</p>
<p><code>     <br />mysql -u root      <br />mysql&gt; FLUSH PRIVILEGES;      <br />mysql&gt; GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY ‘yourpassword’ WITH GRANT OPTION;      <br />mysql&gt; FLUSH PRIVILEGES;      <br />mysql&gt; exit;</code></p>
<p><code>service mysql restart</code></p>
<p>When you’re done, remove the <strong>skip-grant-tables</strong> line from /etc/my.cnf and restart MySQL. Then log into Webhost Manager and reset the password *again*… this is necessary to build a bridge between the linux root user and the MySQL root user, so you can log into MySQL both through WHM’s phpMyAdmin, and SSH without a password when logged into the server as root.</p>
<p>All you need to do now is recompile Apache, but move the MySQL libraries back so easyapache can find them:</p>
<p><code>mv /root/sqllibs/libmysqlclient.* /usr/lib/mysql/</code></p>
<p>I haven’t tested too many configurations yet, but what works for me is Apache 2.2.4 with php 5.2.3, compiled with MySQL and mysqli, but NOT system MySQL.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.server.ruservers.com/2009/01/upgrading-to-mysql-51x-on-cpanel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CPanel: upgrading to MySQL5</title>
		<link>http://blog.server.ruservers.com/2009/01/cpanel-upgrading-to-mysql5/</link>
		<comments>http://blog.server.ruservers.com/2009/01/cpanel-upgrading-to-mysql5/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 14:26:12 +0000</pubDate>
		<dc:creator>Ru Servers</dc:creator>
				<category><![CDATA[Cpanel]]></category>
		<category><![CDATA[MYSQL]]></category>
		<category><![CDATA[Upgrade]]></category>

		<guid isPermaLink="false">http://blog.server.ruservers.com/2009/01/cpanel-upgrading-to-mysql5/</guid>
		<description><![CDATA[&#160; Source : http://www.ducea.com/2006/07/16/cpanel-upgrading-to-mysql5/ &#160; CPanel has included support for MySQL 5 in all its latest releases - 10.8.2-xxx &#8211; (Stable/Release/Current). I find this very cool and it is a big difference in trying to get MySQL4 to run on Plesk for example. Anyway the upgrade process is very simple, and probably no one will [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>Source : <a title="http://www.ducea.com/2006/07/16/cpanel-upgrading-to-mysql5/" href="http://www.ducea.com/2006/07/16/cpanel-upgrading-to-mysql5/">http://www.ducea.com/2006/07/16/cpanel-upgrading-to-mysql5/</a></p>
<p>&#160;</p>
<p><strong>CPanel </strong>has included support for <strong>MySQL 5</strong> in all its latest releases <em>- 10.8.2-xxx &#8211; (Stable/Release/Current)</em>. I find this very cool and it is a big difference in trying to get MySQL4 to run on Plesk for example. Anyway the upgrade process is very simple, and probably no one will need any additional information to complete this safely. I just wanted to point out some of the problems you might encounter in performing this upgrade.    <br /><strong>How can you upgrade to MySQL5</strong>? Simply login to the <strong>WHM </strong>interface, and from “<strong>Server Configuration / Tweak Settings</strong>” choose in the “<strong>MySQL</strong>” section the <strong>5.0 radio button</strong>. Then click “<strong>Save</strong>” and you are done. This will actually run the script: <u>/scripts/mysqlup</u> that will download and install the latest MySQL5 rpms available at that time.    <br />After completion as instructed you should rebuild your perl mysql libraries and rebuild apache (to have php build against the newly installed mysql library).</p>
<pre><code>/scripts/perlinstaller --force Bundle::DBD::mysql</code></pre>
<p>and for apache/php:</p>
<pre><code>/scripts/easyapache</code></pre>
<p>or you can see <a href="http://www.ducea.com/2006/06/20/upgrade-php-on-cpanelwhm/">this post</a> for more details on compiling apache/php on CPanel from WHM.</p>
<p>What should you be aware prior to perform this upgrade? Here are some issues that you might find useful to know before doing this…</p>
<h5>1. The upgrade is not reversible…</h5>
<p>Even if you see the warning and this is even in bold:<br />
  <br /><strong>“Updating from a previous verion of MySQL to a later version is not automaticlly reversable. You should backup your databases if you think you might wish to downgrade in the future.”</strong></p>
<p>you might not believe it… Well I have not believed it as I have performed safely downgrades to mysql4.1 in case of problems on manual installs of mysql. But in this case CPanel <strong>is telling the truth</strong>… After you will complete the upgrade in WHM the choice for MySQL 4.1 (the radio button) will <strong>disappear </strong>and you will no longer be able to choose it. You can probably downgrade manually if you really need to, by downloading the MySQL4 rpms and install them manually from the command line while removing the MySQL5 ones. In this case you might find useful the link to the location of CPanel rpms:</p>
<p><a href="http://updates.cpanel.net/pub/mysqlinstall/">http://updates.cpanel.net/pub/mysqlinstall/<br />
    <br /></a></p>
<h5>2. MySQL might fail to start…</h5>
<p>Since I have done this only on <strong>RHEL4 </strong>servers I am not aware if this problem exists on other distributions as well. But in <a href="http://www.redhat.com/rhel/"><acronym>RHEL</acronym></a> the MySQL5 init script was <strong>failing </strong>after the upgrade with the following error:</p>
<pre><code>/etc/init.d/mysql start
Starting MySQLCouldn't find MySQL manager or server        [FAILED]</code></pre>
<p>Tracking down this error I found out that the MySQL configuration file (<strong>/etc/my.cnf</strong>) installed by the upgrade had a wrong line that was causing this behaviour:</p>
<pre><code>/etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
#old_passwords=1

[mysql.server]
user=mysql
<strong>basedir=/var/lib</strong>    # &lt;= you will need to comment this line
old-passwords = 1

[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid</code></pre>
<p>The line <strong>basedir=/var/lib</strong> was causing the error and in case you are having the same problem commenting out that line will solve the problem and MySQL will start properly.</p>
<p>These are the 2 issues I have found out when upgrading MySQL5 and hopefully you will be aware of them prior to loosing too much time trying to solve them <img alt=";)" src="http://www.ducea.com/wp-includes/images/smilies/icon_wink.gif" /> Besides this MySQL5 is running fine and I have not found any problems in normal operation or with the integration with other CPanel functions. Have fun.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.server.ruservers.com/2009/01/cpanel-upgrading-to-mysql5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL 5.0: When, why and how to upgrade</title>
		<link>http://blog.server.ruservers.com/2009/01/mysql-50-when-why-and-how-to-upgrade/</link>
		<comments>http://blog.server.ruservers.com/2009/01/mysql-50-when-why-and-how-to-upgrade/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 14:24:02 +0000</pubDate>
		<dc:creator>Ru Servers</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[MYSQL]]></category>
		<category><![CDATA[Upgrade]]></category>

		<guid isPermaLink="false">http://blog.server.ruservers.com/2009/01/mysql-50-when-why-and-how-to-upgrade/</guid>
		<description><![CDATA[&#160; Source: http://searchenterpriselinux.techtarget.com/tip/0,289483,sid39_gci1130131,00.html &#160; If a company is running MySQL 4 now and is happy with it, shouldn&#8217;t it stick with that version? Yes and no, says Mike Hillyer, this site&#8217;s resident MySQL expert. In this tip, he discusses when and why MySQL users should upgrade, the benefits of MySQL&#8217;s new features, and how to [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>Source: <a title="http://searchenterpriselinux.techtarget.com/tip/0,289483,sid39_gci1130131,00.html" href="http://searchenterpriselinux.techtarget.com/tip/0,289483,sid39_gci1130131,00.html">http://searchenterpriselinux.techtarget.com/tip/0,289483,sid39_gci1130131,00.html</a></p>
<p>&#160;</p>
<p><i>If a company is running MySQL 4 now and is happy with it, shouldn&#8217;t it stick with that version? Yes and no, says Mike Hillyer, this site&#8217;s resident MySQL expert. In this tip, he discusses when and why MySQL users should upgrade, the benefits of MySQL&#8217;s new features, and how to evaluate and deploy the upcoming MySQL 5.0, now available in its beta release. </i></p>
<p>Many companies keep a policy of staying one version back from the latest release, meaning that they use Windows 2000 instead of Windows XP, MySQL 4 instead of 4.1, and so on. Such a policy promotes stability over features. </p>
<p>So, companies that find MySQL 4 sufficient for their needs may want to stay where they are because MySQL 4 and MySQL 4.1 are quite stable at the moment and work reliably. </p>
<p>Why would that company want to move to MySQL 5 now? The biggest three features of interest to most companies are stored procedures, triggers, and views. </p>
<p><b>MySQL 5&#8242;s big bonuses</b></p>
<p>Stored procedures allow you to move business logic from end applications to the MySQL server, which can save effort when you have multiple end applications (instead of implementing a price calculation routine in PHP for the web and VC for the desktop, you can implement it in a stored procedure and call it from both PHP and VC). </p>
<p>Stored procedures can also enhance security by allowing you to prevent a user from accessing a table directly, but instead giving them permission to call a stored procedure that has access to the table. </p>
<p>Triggers are stored routines that are written with a syntax like that of stored procedures, but instead of being called by a user or application, triggers are activated by table events such as inserts, updates, and deletes. The triggers can modify or abort the triggering table actions, or take the information provided by the action and use it elsewhere. </p>
<p>I recently used a trigger to create a MyISAM FULLTEXT lookup table for an InnoDB table: any inserts, updates, or deletes to the InnoDB table were mirrored to the lookup table by triggers, and the end users didn&#8217;t have to change anything about the way they interacted with the InnoDB table. </p>
<p>Views are essentially named virtual tables defined by SQL queries. I can take a complex set of tables, create a SELECT query that might be more meaningful to end users, then turn it into a view. The end users can then perform SELECT queries against the view and, in most cases, also execute INSERT, UPDATE, and DELETE statements against the view, with the changes being reflected in the underlying tables. Views help to simplify complicated data and also enhance security. As with a stored procedure, you can create a view and give a user permission to SELECT from the view but not the underlying table. </p>
<p><b>Evaluating MySQL 5</b></p>
<p>In the end most users will eventually move to MySQL 5 as MySQL 4 and 4.1 age and become outdated. The timing will have to depend on whether you consider the features of MySQL 5 to be useful to your organization. </p>
<p>When evaluating the new features, I would recommend installing MySQL 5 on a separate machine and trying it with your existing applications, run as many tests as you can and see if everything runs smoothly. If you do not encounter any errors you can then bring MySQL 5 into your production systems (after a production release of MySQL 5). </p>
<p>There really should not be things to watch out for, in the sense of bugs or incompatibilities, but you can always watch the changelogs at <a href="http://dev.mysql.com/doc/mysql/en/news-5-0-x.html">the 5.0 news page on MySQL&#8217;s site</a> and look for entries that are marked &#8216;Incompatible Change&#8217;. </p>
<p>So far, bug reports have been many and varied, depending on the feature being used. As expected, most of the bugs are related to new MySQL features, such as stored procedures, triggers, and views. The full list of features added and bugs fixed can be browsed in <a href="http://dev.mysql.com/doc/mysql/en/news-5-0-x.html">MySQL&#8217;s 5.0 news</a>. </p>
<p><b>Preparing for an upgrade</b></p>
<p>The best tip before upgrading is to back up your data: while the upgrade process should be relatively painless, not having a backup is a recipe for disaster. </p>
<p>Those looking to upgrade major versions of MySQL in a production environment should test and evaluate their systems before upgrading. The ideal would be to install all software on a test machine, upgrade the MySQL installation on the test machine to MySQL 5, and then run the test machine with real data for a while to ensure there are no suprises. If all goes well on the test machine you can then move the production systems to the newer version. </p>
<p>Production machines should also only be upgraded to a production version of MySQL. While the beta versions of MySQL have been very stable, there are no guarantees that your application will run flawlessly on beta software. </p>
<p>A common error when upgrading from MySQL 4.0 to MySQL 4.1 is password hashing. Users who encounter an error such as &quot;Client does not support authentication protocol requested&quot; can find at solution at <a href="http://www.openwin.org/mike/index.php/faq/mysql/error-client-does-not-support-authentication-protocol-requested/">OpenWin.org.</a></p>
<p>There are detailed upgrade notes for all versions of MySQL on this <a href="http://dev.mysql.com/doc/mysql/en/upgrade.html">MySQL.com page.</a></p>
<p>Most applications should not have any problem with MySQL 5, as opposed to MySQL 4.1. However, users upgrading from MySQL 4.0 should first upgrade to MySQL 4.1, then upgrade to MySQL 5. You can get all MySQL downloads on <a href="http://dev.mysql.com/downloads/">MySQL&#8217;s download page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.server.ruservers.com/2009/01/mysql-50-when-why-and-how-to-upgrade/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrading from MySQL 4.1 to 5.0</title>
		<link>http://blog.server.ruservers.com/2009/01/upgrading-from-mysql-41-to-50/</link>
		<comments>http://blog.server.ruservers.com/2009/01/upgrading-from-mysql-41-to-50/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 14:22:05 +0000</pubDate>
		<dc:creator>Ru Servers</dc:creator>
				<category><![CDATA[MYSQL]]></category>
		<category><![CDATA[Upgrade]]></category>

		<guid isPermaLink="false">http://blog.server.ruservers.com/2009/01/upgrading-from-mysql-41-to-50/</guid>
		<description><![CDATA[&#160; Source: http://dev.mysql.com/doc/refman/5.0/en/upgrading-from-4-1.html &#160; Note It is good practice to back up your data before installing any new version of software. Although MySQL works very hard to ensure a high level of quality, you should protect your data by making a backup. MySQL recommends that you dump and reload your tables from any previous version [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>Source: <a title="http://dev.mysql.com/doc/refman/5.0/en/upgrading-from-4-1.html" href="http://dev.mysql.com/doc/refman/5.0/en/upgrading-from-4-1.html">http://dev.mysql.com/doc/refman/5.0/en/upgrading-from-4-1.html</a></p>
<p>&#160;</p>
<p><a name="id2764545"></a><a name="id2764558"></a><b>Note</b></p>
<p>It is good practice to back up your data before installing any new version of software. Although MySQL works very hard to ensure a high level of quality, you should protect your data by making a backup. MySQL recommends that you dump and reload your tables from any previous version to upgrade to 5.0. </p>
<p>In general, you should do the following when upgrading from MySQL 4.1 to 5.0: </p>
<ul>
<li>Read <i>all</i> the items in the following sections to see whether any of them might affect your applications:
<ul>
<li><a href="http://dev.mysql.com/doc/refman/5.0/en/upgrade.html">Section 2.18, “Upgrading MySQL”</a>, has general update information. </li>
<li>The items in the change lists found later in this section enable you to identify upgrade issues that apply to your current MySQL installation. </li>
<li>The MySQL 5.0 change history describes significant new features you can use in 5.0 or that differ from those found in MySQL 4.1. Some of these changes may result in incompatibilities. See <a href="http://dev.mysql.com/doc/refman/5.0/en/news-5-0-x.html">Section E.1, “Changes in release 5.0.x (Production)”</a>. </li>
</ul>
</li>
<li>Note particularly any changes that are marked <b>Known issue</b> or <b>Incompatible change</b>. These incompatibilities with earlier versions of MySQL may require your attention <i>before you upgrade</i>. </li>
</ul>
<p>Our aim is to avoid these changes, but occasionally they are necessary to correct problems that would be worse than an incompatibility between releases. If any upgrade issue applicable to your installation involves an incompatibility that requires special handling, follow the instructions given in the incompatibility description. Often this will involve a dump and reload, or use of a statement such as <a href="http://dev.mysql.com/doc/refman/5.0/en/check-table.html">CHECK TABLE</a> or <a href="http://dev.mysql.com/doc/refman/5.0/en/repair-table.html">REPAIR TABLE</a>. </p>
<p>A dump and reload is done like this: </p>
<ul>
<ul>
<li>Dump the affected tables with <a href="http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html"><b>mysqldump</b></a> <i>before</i> upgrading </li>
<li>Reload the dump file (for example, with <a href="http://dev.mysql.com/doc/refman/5.0/en/mysql.html"><b>mysql</b></a>) to recreate the tables after upgrading </li>
</ul>
</ul>
<p>Any procedure that involves <a href="http://dev.mysql.com/doc/refman/5.0/en/repair-table.html">REPAIR TABLE</a> with the USE_FRM option <i>must</i> be done before upgrading. Use of this statement with a version of MySQL different from the one used to create the table (that is, using it after upgrading) may damage the table. See <a href="http://dev.mysql.com/doc/refman/5.0/en/repair-table.html">Section 12.5.2.6, “REPAIR TABLE Syntax”</a>. </p>
<ul>
<li>After you upgrade to a new version of MySQL, run <a href="http://dev.mysql.com/doc/refman/5.0/en/mysql-upgrade.html"><b>mysql_upgrade</b></a> (see <a href="http://dev.mysql.com/doc/refman/5.0/en/mysql-upgrade.html">Section 4.4.9, “<b>mysql_upgrade</b> — Check Tables for MySQL Upgrade”</a>). This program will check your tables, and repair them if necessary. It will also update your grant tables to make sure that they have the current structure so that you can take advantage of any new capabilities. (Some releases of MySQL introduce changes to the structure of the grant tables to add new privileges or features.) </li>
<li>If you are running MySQL Server on Windows, see <a href="http://dev.mysql.com/doc/refman/5.0/en/windows-upgrading.html">Section 2.9.14, “Upgrading MySQL on Windows”</a>. </li>
<li>MySQL 5.0 adds support for stored procedures. This support requires the mysql.proc table. To create this table, you should run the <a href="http://dev.mysql.com/doc/refman/5.0/en/mysql-upgrade.html"><b>mysql_upgrade</b></a> program as described in <a href="http://dev.mysql.com/doc/refman/5.0/en/mysql-upgrade.html">Section 4.4.9, “<b>mysql_upgrade</b> — Check Tables for MySQL Upgrade”</a>. </li>
<li>MySQL 5.0 adds support for views. This support requires extra privilege columns in the mysql.user and mysql.db tables. To create these columns, you should run the <a href="http://dev.mysql.com/doc/refman/5.0/en/mysql-upgrade.html"><b>mysql_upgrade</b></a> program as described in <a href="http://dev.mysql.com/doc/refman/5.0/en/mysql-upgrade.html">Section 4.4.9, “<b>mysql_upgrade</b> — Check Tables for MySQL Upgrade”</a>. </li>
<li>If you are using replication, see <a href="http://dev.mysql.com/doc/refman/5.0/en/replication-upgrade.html">Section 16.3.3, “Upgrading a Replication Setup”</a>, for information on upgrading your replication setup. </li>
</ul>
<p>Several visible behaviors have changed between MySQL 4.1 and MySQL 5.0 to make MySQL more compatible with standard SQL. These changes may affect your applications. </p>
<p>The following lists describe changes that may affect applications and that you should watch out for when upgrading to MySQL 5.0. </p>
<p><b>Server Changes:</b></p>
<ul>
<li><b>Incompatible change</b>: The indexing order for end-space in <a href="http://dev.mysql.com/doc/refman/5.0/en/blob.html">TEXT</a> columns for InnoDB and MyISAM tables has changed. Starting from 5.0.3, <a href="http://dev.mysql.com/doc/refman/5.0/en/blob.html">TEXT</a> indexes are compared as space-padded at the end (just as MySQL sorts <a href="http://dev.mysql.com/doc/refman/5.0/en/char.html">CHAR</a>, <a href="http://dev.mysql.com/doc/refman/5.0/en/char.html">VARCHAR</a> and <a href="http://dev.mysql.com/doc/refman/5.0/en/blob.html">TEXT</a> fields). If you have a index on a <a href="http://dev.mysql.com/doc/refman/5.0/en/blob.html">TEXT</a> column, you should run <a href="http://dev.mysql.com/doc/refman/5.0/en/check-table.html">CHECK TABLE</a> on it. If the check reports errors, rebuild the indexes: Dump and reload the table if it is an InnoDB table, or run <a href="http://dev.mysql.com/doc/refman/5.0/en/optimize-table.html">OPTIMIZE TABLE</a> or <a href="http://dev.mysql.com/doc/refman/5.0/en/repair-table.html">REPAIR TABLE</a> if it is a MyISAM table. </li>
<li><b>Incompatible change</b>. For <a href="http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html">BINARY</a> columns, the pad value and how it is handled has changed as of MySQL 5.0.15. The pad value for inserts now is 0&#215;00 rather than space, and there is no stripping of the pad value for retrievals. For details, see <a href="http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html">Section 10.4.2, “The BINARY and VARBINARY Types”</a>. </li>
<li><b>Incompatible change</b>: As of MySQL 5.0.3, the server by default no longer loads user-defined functions (UDFs) unless they have at least one auxiliary symbol (for example, an xxx_init or xxx_deinit symbol) defined in addition to the main function symbol. This behavior can be overridden with the &#8211;allow-suspicious-udfs option. See <a href="http://dev.mysql.com/doc/refman/5.0/en/udf-security.html">Section 21.2.2.6, “User-Defined Function Security Precautions”</a>. </li>
<li><b>Incompatible change</b>: As of MySQL 5.0.13, InnoDB rolls back only the last statement on a transaction timeout. In MySQL 5.0.32, a new option, &#8211;innodb_rollback_on_timeout, causes InnoDB to abort and roll back the entire transaction if a transaction timeout occurs (the same behavior as in MySQL 4.1). </li>
<li><b>Incompatible change</b>: For <a href="http://dev.mysql.com/doc/refman/5.0/en/enum.html">ENUM</a> columns that had enumeration values containing commas, the commas were mapped to 0xff internally. However, this rendered the commas indistinguishable from true 0xff characters in the values. This no longer occurs. However, the fix requires that you dump and reload any tables that have <a href="http://dev.mysql.com/doc/refman/5.0/en/enum.html">ENUM</a> columns containing true 0xff in their values: Dump the tables using <a href="http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html"><b>mysqldump</b></a> with the current server before upgrading from a version of MySQL 5.0 older than 5.0.36 to version 5.0.36 or newer. </li>
<li><b>Incompatible change</b>: The update log has been removed in MySQL 5.0. If you had enabled it previously, you should enable the binary log instead. </li>
<li><a name="id2765188"></a><b>Incompatible change:</b> Support for the ISAM storage engine has been removed in MySQL 5.0. If you have any ISAM tables, you should convert them <i>before</i> upgrading. For example, to convert an ISAM table to use the MyISAM storage engine, use this statement: </li>
</ul>
<p>· ALTER TABLE <i>tbl_name</i> ENGINE = MyISAM;</p>
<p>Use a similar statement for every ISAM table in each of your databases. </p>
<ul>
<li><a name="id2765272"></a><b>Incompatible change</b>: Support for RAID options in MyISAM tables has been removed in MySQL 5.0. If you have tables that use these options, you should convert them before upgrading. One way to do this is to dump them with <a href="http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html"><b>mysqldump</b></a>, edit the dump file to remove the RAID options in the <a href="http://dev.mysql.com/doc/refman/5.0/en/create-table.html">CREATE TABLE</a> statements, and reload the dump file. Another possibility is to use CREATE TABLE <i>new_tbl</i> &#8230; SELECT <i>raid_tbl</i> to create a new table from the RAID table. However, the <a href="http://dev.mysql.com/doc/refman/5.0/en/create-table.html">CREATE TABLE</a> part of the statement must contain sufficient information to re-create column attributes as well as indexes, or column attributes may be lost and indexes will not appear in the new table. See <a href="http://dev.mysql.com/doc/refman/5.0/en/create-table.html">Section 12.1.10, “CREATE TABLE Syntax”</a>. </li>
</ul>
<p>The .MYD files for RAID tables in a given database are stored under the database directory in subdirectories that have names consisting of two hex digits in the range from 00 to ff. After converting all tables that use RAID options, these RAID-related subdirectories still will exist but can be removed. Verify that they are empty, and then remove them manually. (If they are not empty, there is some RAID table that has not been converted.) </p>
<ul>
<li><b>Incompatible change</b>: Beginning with MySQL 5.0.42, when a <a href="http://dev.mysql.com/doc/refman/5.0/en/datetime.html">DATE</a> value is compared with a <a href="http://dev.mysql.com/doc/refman/5.0/en/datetime.html">DATETIME</a> value, the <a href="http://dev.mysql.com/doc/refman/5.0/en/datetime.html">DATE</a> value is coerced to the <a href="http://dev.mysql.com/doc/refman/5.0/en/datetime.html">DATETIME</a> type by adding the time portion as 00:00:00. Previously, the time portion of the <a href="http://dev.mysql.com/doc/refman/5.0/en/datetime.html">DATETIME</a> value was ignored, or the comparison could be performed as a string comparison. To mimic the old behavior, use the <a href="http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html#function_cast">CAST()</a> function as shonw in this example: SELECT <i>date_col</i> = CAST(NOW() AS DATE) FROM <i>table</i>;. </li>
<li>As of MySQL 5.0.25, the <a href="http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_lc_time_names">lc_time_names</a> system variable specifies the locale that controls the language used to display day and month names and abbreviations. This variable affects the output from the <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format">DATE_FORMAT()</a>, <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_dayname">DAYNAME()</a> and <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_monthname">MONTHNAME()</a> functions. See <a href="http://dev.mysql.com/doc/refman/5.0/en/locale-support.html">Section 9.8, “MySQL Server Locale Support”</a>. </li>
<li>In MySQL 5.0.6, binary logging of stored routines and triggers was changed. This change has implications for security, replication, and data recovery, as discussed in <a href="http://dev.mysql.com/doc/refman/5.0/en/stored-programs-logging.html">Section 18.5, “Binary Logging of Stored Programs”</a>. </li>
<li>As of MySQL 5.0.28, <a href="http://dev.mysql.com/doc/refman/5.0/en/mysqld-safe.html"><b>mysqld_safe</b></a> no longer implicitly invokes <b>mysqld-max</b> if it exists. Instead, it invokes <a href="http://dev.mysql.com/doc/refman/5.0/en/mysqld.html"><b>mysqld</b></a> unless a &#8211;mysqld or &#8211;mysqld-version option is given to specify another server explicitly. If you previously relied on the implicit invocation of <b>mysqld-max</b>, you should use an appropriate option now. </li>
</ul>
<p><b>SQL Changes:</b></p>
<ul>
<li><b>Important note</b>: Prior to MySQL 5.0.46, the parser accepted invalid code in SQL condition handlers, leading to server crashes or unexpected execution behavior in stored programs. Specifically, the parser allowed a condition handler to refer to labels for blocks that enclose the handler declaration. This was incorrect because block label scope does not include the code for handlers declared within the labeled block. </li>
</ul>
<p>As of 5.0.46, the parser rejects this invalid construct, but if you upgrade in place (without dumping and reloading your databases), existing handlers that contain the construct still are invalid <i>even if they appear to function as you expect</i> and should be rewritten. </p>
<p>To find affected handlers, use mysqldump to dump all stored functions and procedures, triggers, and events. Then attempt to reload them into an upgraded server. Handlers that contain illegal label references will be rejected. </p>
<p>For more information about condition handlers and writing them to avoid invalid jumps, see <a href="http://dev.mysql.com/doc/refman/5.0/en/declare-handler.html">Section 12.8.4.2, “DECLARE for Handlers”</a>. </p>
<ul>
<li><b>Incompatible change</b>: If you have created a user-defined function (UDF) with a given name and upgrade MySQL to a version that implements a new built-in function with the same name, the UDF becomes inaccessible. To correct this, use <a href="http://dev.mysql.com/doc/refman/5.0/en/drop-function.html">DROP FUNCTION</a> to drop the UDF, and then use <a href="http://dev.mysql.com/doc/refman/5.0/en/create-function.html">CREATE FUNCTION</a> to re-create the UDF with a different non-conflicting name. If a new version of MySQL implements a built-in function with the same name as an existing stored function, you have two choices: Rename the stored function to use a non-conflicting name, or change calls to the function so that they use a database qualifier (that is, use <i>db_name</i>.<i>func_name</i>() syntax). See <a href="http://dev.mysql.com/doc/refman/5.0/en/function-resolution.html">Section 8.2.3, “Function Name Parsing and Resolution”</a>, for the rules describing how the server interprets references to different kinds of functions. </li>
<li><b>Incompatible change:</b> The parser accepted statements that contained /* &#8230; */ that were not properly closed with */, such as SELECT 1 /* + 2. As of MySQL 5.0.50, statements that contain unclosed /*-comments now are rejected with a syntax error. </li>
</ul>
<p>This fix has the potential to cause incompatibilities. Because of <a href="http://bugs.mysql.com/26302">Bug#26302</a>, which caused the trailing */ to be truncated from comments in views, stored routines, triggers, and events, it is possible that objects of those types may have been stored with definitions that now will be rejected as syntactically invalid. Such objects should be dropped and re-created so that their definitions do not contain truncated comments. If a stored object definition contains only a single statement (does not use a BEGIN &#8230; END block) and contains a comment within the statement, the comment should be moved to follow the statement or the object should be rewritten to use a BEGIN &#8230; END block. For example, this statement: </p>
<p>CREATE PROCEDURE p() SELECT 1 /* my comment */ ;</p>
<p>Can be rewritten in either of these ways: </p>
<p>CREATE PROCEDURE p() SELECT 1; /* my comment */</p>
<p>CREATE PROCEDURE p() BEGIN SELECT 1 /* my comment */ ; END;</p>
<ul>
<li><b>Incompatible change:</b> Beginning with MySQL 5.0.12, natural joins and joins with USING, including outer join variants, are processed according to the SQL:2003 standard. The changes include elimination of redundant output columns for NATURAL joins and joins specified with a USING clause and proper ordering of output columns. The precedence of the comma operator also now is lower compared to JOIN, LEFT JOIN, and so forth. </li>
</ul>
<p>These changes make MySQL more compliant with standard SQL. However, they can result in different output columns for some joins. Also, some queries that appeared to work correctly prior to 5.0.12 must be rewritten to comply with the standard. For details about the scope of the changes and examples that show what query rewrites are necessary, see <a href="http://dev.mysql.com/doc/refman/5.0/en/join.html">Section 12.2.8.1, “JOIN Syntax”</a>. </p>
<ul>
<li><b>Incompatible change:</b> The namespace for triggers has changed in MySQL 5.0.10. Previously, trigger names had to be unique per table. Now they must be unique within the schema (database). An implication of this change is that <a href="http://dev.mysql.com/doc/refman/5.0/en/drop-trigger.html">DROP TRIGGER</a> syntax now uses a schema name instead of a table name (schema name is optional and, if omitted, the current schema will be used). </li>
</ul>
<p>After upgrading from a previous version of MySQL 5 to MySQL 5.0.10 or newer, you must drop all triggers and re-create them or <a href="http://dev.mysql.com/doc/refman/5.0/en/drop-trigger.html">DROP TRIGGER</a> will not work after the upgrade. Here is a suggested procedure for doing this: </p>
<ul>
<ol>
<li>Upgrade to MySQL 5.0.10 or later to be able to access trigger information in the <a href="http://dev.mysql.com/doc/refman/5.0/en/triggers-table.html">INFORMATION_SCHEMA.TRIGGERS</a> table. (It should work even for pre-5.0.10 triggers.) </li>
<li>Dump all trigger definitions using the following <a href="http://dev.mysql.com/doc/refman/5.0/en/select.html">SELECT</a> statement: </li>
</ol>
</ul>
<p>3. SELECT CONCAT(&#8216;CREATE TRIGGER &#8216;, t.TRIGGER_SCHEMA, &#8216;.&#8217;, t.TRIGGER_NAME,</p>
<p>4. &#8216; &#8216;, t.ACTION_TIMING, &#8216; &#8216;, t.EVENT_MANIPULATION, &#8216; ON &#8216;,</p>
<p>5. t.EVENT_OBJECT_SCHEMA, &#8216;.&#8217;, t.EVENT_OBJECT_TABLE,</p>
<p>6. &#8216; FOR EACH ROW &#8216;, t.ACTION_STATEMENT, &#8216;//&#8217; )</p>
<p>7. INTO OUTFILE &#8216;/tmp/triggers.sql&#8217;</p>
<p>8. FROM INFORMATION_SCHEMA.TRIGGERS AS t;</p>
<p>The statement uses INTO OUTFILE, so you must have the FILE privilege. The file will be created on the server host. Use a different filename if you like. To be 100% safe, inspect the trigger definitions in the triggers.sql file, and perhaps make a backup of the file. </p>
<ul>
<ol start="start">
<li>Stop the server and drop all triggers by removing all .TRG files in your database directories. Change location to your data directory and issue this command: </li>
</ol>
</ul>
<p>10.shell&gt; <b>rm */*.TRG</b></p>
<ul>
<ol start="start">
<li>Start the server and re-create all triggers using the triggers.sql file. For the file created earlier, use these commands in the <a href="http://dev.mysql.com/doc/refman/5.0/en/mysql.html"><b>mysql</b></a> program: </li>
</ol>
</ul>
<p>12.mysql&gt; <b>delimiter // ;</b></p>
<p>13.mysql&gt; <b>source /tmp/triggers.sql //</b></p>
<ul>
<ol start="start">
<li>Use the SHOW TRIGGERS statement to check that all triggers were created successfully. </li>
</ol>
<li><b>Incompatible change:</b> As of MySQL 5.0.15, the <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_char">CHAR()</a> function returns a binary string rather than a string in the connection character set. An optional USING <i>charset_name</i> clause may be used to produce a result in a specific character set instead. Also, arguments larger than 256 produce multiple characters. They are no longer interpreted modulo 256 to produce a single character each. These changes may cause some incompatibilities: </li>
</ul>
<ul>
<ul>
<li>CHAR(ORD(&#8216;A&#8217;)) = &#8216;a&#8217; is no longer true: </li>
</ul>
</ul>
<p>o mysql&gt; <b>SELECT CHAR(ORD(&#8216;A&#8217;)) = &#8216;a&#8217;;</b></p>
<p>o +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+</p>
<p>o | CHAR(ORD(&#8216;A&#8217;)) = &#8216;a&#8217; |</p>
<p>o +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+</p>
<p>o | 0 |</p>
<p>o +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+</p>
<p>To perform a case-insensitive comparison, you can produce a result string in a non-binary character set by adding a USING clause or converting the result: </p>
<p>mysql&gt; <b>SELECT CHAR(ORD(&#8216;A&#8217;) USING latin1) = &#8216;a&#8217;;</b></p>
<p>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+</p>
<p>| CHAR(ORD(&#8216;A&#8217;) USING latin1) = &#8216;a&#8217; |</p>
<p>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+</p>
<p>| 1 |</p>
<p>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+</p>
<p>mysql&gt; <b>SELECT CONVERT(CHAR(ORD(&#8216;A&#8217;)) USING latin1) = &#8216;a&#8217;;</b></p>
<p>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+</p>
<p>| CONVERT(CHAR(ORD(&#8216;A&#8217;)) USING latin1) = &#8216;a&#8217; |</p>
<p>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+</p>
<p>| 1 |</p>
<p>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+</p>
<ul>
<ul>
<li>CREATE TABLE &#8230; SELECT CHAR(&#8230;) produces a <a href="http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html">VARBINARY</a> column, not a <a href="http://dev.mysql.com/doc/refman/5.0/en/char.html">VARCHAR</a> column. To produce a <a href="http://dev.mysql.com/doc/refman/5.0/en/char.html">VARCHAR</a> column, use USING or <a href="http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html#function_convert">CONVERT()</a> as just described to convert the <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_char">CHAR()</a> result into a non-binary character set. </li>
<li>Previously, the following statements inserted the value 0&#215;00410041 (&#8216;AA&#8217; as a ucs2 string) into the table: </li>
</ul>
</ul>
<p>o CREATE TABLE t (ucs2_column CHAR(2) CHARACTER SET ucs2);</p>
<p>o INSERT INTO t VALUES (CHAR(0&#215;41,0&#215;41));</p>
<p>As of MySQL 5.0.15, the statements insert a single ucs2 character with value 0&#215;4141. </p>
<ul>
<li><b>Incompatible change:</b> By default, integer subtraction involving an unsigned value should produce an unsigned result. Tracking of the “unsignedness” of an expression was improved in MySQL 5.0.13. This means that, in some cases where an unsigned subtraction would have resulted in a signed integer, it now results in an unsigned integer. One context in which this difference manifests itself is when a subtraction involving an unsigned operand would be negative. </li>
</ul>
<p>Suppose that i is a TINYINT UNSIGNED column and has a value of 0. The server evaluates the following expression using 64-bit unsigned integer arithmetic with the following result: </p>
<p>mysql&gt; <b>SELECT i &#8211; 1 FROM t;</b></p>
<p>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+</p>
<p>| i &#8211; 1 |</p>
<p>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+</p>
<p>| 18446744073709551615 |</p>
<p>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+</p>
<p>If the expression is used in an UPDATE t SET i = i &#8211; 1 statement, the expression is evaluated and the result assigned to i according to the usual rules for handling values outside the column range or 0 to 255. That is, the value is clipped to the nearest endpoint of the range. However, the result is version-specific: </p>
<ul>
<ul>
<li>Before MySQL 5.0.13, the expression is evaluated but is treated as the equivalent 64-bit signed value (–1) for the assignment. The value of –1 is clipped to the nearest endpoint of the column range, resulting in a value of 0: </li>
</ul>
</ul>
<p>o mysql&gt; <b>UPDATE t SET i = i &#8211; 1; SELECT i FROM t;</b></p>
<p>o +&#8212;&#8212;+</p>
<p>o | i |</p>
<p>o +&#8212;&#8212;+</p>
<p>o | 0 |</p>
<p>o +&#8212;&#8212;+</p>
<ul>
<ul>
<li>As of MySQL 5.0.13, the expression is evaluated and retains its unsigned attribute for the assignment. The value of 18446744073709551615 is clipped to the nearest endpoint of the column range, resulting in a value of 255: </li>
</ul>
</ul>
<p>o mysql&gt; <b>UPDATE t SET i = i &#8211; 1; SELECT i FROM t;</b></p>
<p>o +&#8212;&#8212;+</p>
<p>o | i |</p>
<p>o +&#8212;&#8212;+</p>
<p>o | 255 |</p>
<p>o +&#8212;&#8212;+</p>
<p>To get the older behavior, use <a href="http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html#function_cast">CAST()</a> to convert the expression result to a signed value: </p>
<p>UPDATE t SET i = CAST(i &#8211; 1 AS SIGNED);</p>
<p>Alternatively, set the <a href="http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html#sqlmode_no_unsigned_subtraction">NO_UNSIGNED_SUBTRACTION</a> SQL mode. However, this will affect all integer subtractions involving unsigned values. </p>
<ul>
<li><b>Incompatible change:</b> Before MySQL 5.0.13, <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_now">NOW()</a> and <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_sysdate">SYSDATE()</a> return the same value (the time at which the statement in which the function occurs begins executing). As of MySQL 5.0.13, <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_sysdate">SYSDATE()</a> returns the time at which it executes, which can differ from the value returned by <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_now">NOW()</a>. For information about the implications for binary logging, replication, and use of indexes, see the description for <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_sysdate">SYSDATE()</a> in <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html">Section 11.6, “Date and Time Functions”</a> and for SET TIMESTAMP in <a href="http://dev.mysql.com/doc/refman/5.0/en/set-option.html">Section 12.5.4, “SET Syntax”</a>. To restore the former behavior for <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_sysdate">SYSDATE()</a> and cause it to be an alias for <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_now">NOW()</a>, start the server with the &#8211;sysdate-is-now option (available as of MySQL 5.0.20). </li>
<li><b>Incompatible change:</b> Before MySQL 5.0.13, <a href="http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_greatest">GREATEST(<i>x</i>,NULL)</a> and <a href="http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_least">LEAST(<i>x</i>,NULL)</a> return <i>x</i> when <i>x</i> is a non-NULL value. As of 5.0.3, both functions return NULL if any argument is NULL, the same as Oracle. This change can cause problems for applications that rely on the old behavior. </li>
<li><b>Incompatible change:</b> Before MySQL 4.1.13/5.0.8, conversion of <a href="http://dev.mysql.com/doc/refman/5.0/en/datetime.html">DATETIME</a> values to numeric form by adding zero produced a result in YYYYMMDDHHMMSS format. The result of DATETIME+0 is now in YYYYMMDDHHMMSS.000000 format. </li>
<li><b>Incompatible change:</b> In MySQL 4.1.12/5.0.6, the behavior of <a href="http://dev.mysql.com/doc/refman/5.0/en/load-data.html">LOAD DATA INFILE</a> and <a href="http://dev.mysql.com/doc/refman/5.0/en/select.html">SELECT &#8230; INTO OUTFILE</a> has changed when the FIELDS TERMINATED BY and FIELDS ENCLOSED BY values both are empty. Formerly, a column was read or written the display width of the column. For example, INT(4) was read or written using a field with a width of 4. Now columns are read and written using a field width wide enough to hold all values in the field. However, data files written before this change was made might not be reloaded correctly with <a href="http://dev.mysql.com/doc/refman/5.0/en/load-data.html">LOAD DATA INFILE</a> for MySQL 4.1.12/5.0.6 and up. This change also affects data files read by <a href="http://dev.mysql.com/doc/refman/5.0/en/mysqlimport.html"><b>mysqlimport</b></a> and written by <a href="http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html"><b>mysqldump &#8211;tab</b></a>, which use <a href="http://dev.mysql.com/doc/refman/5.0/en/load-data.html">LOAD DATA INFILE</a> and <a href="http://dev.mysql.com/doc/refman/5.0/en/select.html">SELECT &#8230; INTO OUTFILE</a>. For more information, see <a href="http://dev.mysql.com/doc/refman/5.0/en/load-data.html">Section 12.2.6, “LOAD DATA INFILE Syntax”</a>. </li>
<li><b>Incompatible change</b>: The implementation of <a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html">DECIMAL</a> has changed in MySQL 5.0.3. You should make your applications aware of this change. For information about this change, and about possible incompatibilities with old applications, see <a href="http://dev.mysql.com/doc/refman/5.0/en/precision-math.html">Section 11.13, “Precision Math”</a>, in particular, <a href="http://dev.mysql.com/doc/refman/5.0/en/precision-math-decimal-changes.html">Section 11.13.2, “DECIMAL Data Type Changes”</a>. </li>
</ul>
<p><a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html">DECIMAL</a> columns are stored in a more efficient format. To convert a table to use the new <a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html">DECIMAL</a> type, you should do an <a href="http://dev.mysql.com/doc/refman/5.0/en/alter-table.html">ALTER TABLE</a> on it. (The <a href="http://dev.mysql.com/doc/refman/5.0/en/alter-table.html">ALTER TABLE</a> also will change the table&#8217;s <a href="http://dev.mysql.com/doc/refman/5.0/en/char.html">VARCHAR</a> columns to use the new <a href="http://dev.mysql.com/doc/refman/5.0/en/char.html">VARCHAR</a> data type properties, described in a separate item.) </p>
<p>A consequence of the change in handling of the <a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html">DECIMAL</a> and <a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html">NUMERIC</a> fixed-point data types is that the server is more strict to follow standard SQL. For example, a data type of DECIMAL(3,1) stores a maximum value of 99.9. Before MySQL 5.0.3, the server allowed larger numbers to be stored. That is, it stored a value such as 100.0 as 100.0. As of MySQL 5.0.3, the server clips 100.0 to the maximum allowable value of 99.9. If you have tables that were created before MySQL 5.0.3 and that contain floating-point data not strictly legal for the data type, you should alter the data types of those columns. For example: </p>
<p>ALTER TABLE <i>tbl_name</i> MODIFY <i>col_name</i> DECIMAL(4,1);</p>
<p>The behavior used by the server for <a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html">DECIMAL</a> columns in a table depends on the version of MySQL used to create the table. If your server is from MySQL 5.0.3 or higher, but you have <a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html">DECIMAL</a> columns in tables that were created before 5.0.3, the old behavior still applies to those columns. To convert the tables to the newer <a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html">DECIMAL</a> format, dump them with <a href="http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html"><b>mysqldump</b></a> and reload them. </p>
<ul>
<li><b>Incompatible change:</b> MySQL 5.0.3 and up uses precision math when calculating with <a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html">DECIMAL</a> and integer columns (64 decimal digits) and for rounding exact-value numbers. Rounding behavior is well-defined, not dependent on the implementation of the underlying C library. However, this might result in incompatibilities for applications that rely on the old behavior. (For example, inserting .5 into an <a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html">INT</a> column results in 1 as of MySQL 5.0.3, but might be 0 in older versions.) For more information about rounding behavior, see <a href="http://dev.mysql.com/doc/refman/5.0/en/precision-math-rounding.html">Section 11.13.4, “Rounding Behavior”</a>, and <a href="http://dev.mysql.com/doc/refman/5.0/en/precision-math-examples.html">Section 11.13.5, “Precision Math Examples”</a>. </li>
<li><b>Incompatible change</b>: MyISAM and InnoDB tables created with <a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html">DECIMAL</a> columns in MySQL 5.0.3 to 5.0.5 will appear corrupt after an upgrade to MySQL 5.0.6. (The same incompatibility will occur for these tables created in MySQL 5.0.6 after a downgrade to MySQL 5.0.3 to 5.0.5.) If you have such tables, check and repair them with <a href="http://dev.mysql.com/doc/refman/5.0/en/mysql-upgrade.html"><b>mysql_upgrade</b></a> after upgrading. See <a href="http://dev.mysql.com/doc/refman/5.0/en/mysql-upgrade.html">Section 4.4.9, “<b>mysql_upgrade</b> — Check Tables for MySQL Upgrade”</a>. </li>
<li><b>Incompatible change:</b> For user-defined functions, exact-value decimal arguments such as 1.3 or <a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html">DECIMAL</a> column values were passed as REAL_RESULT values prior to MySQL 5.0.3. As of 5.0.3, they are passed as strings with a type of DECIMAL_RESULT. If you upgrade to 5.0.3 and find that your UDF now receives string values, use the initialization function to coerce the arguments to numbers as described in <a href="http://dev.mysql.com/doc/refman/5.0/en/udf-arguments.html">Section 21.2.2.3, “UDF Argument Processing”</a>. </li>
<li><b>Incompatible change:</b> Before MySQL 5.0.2, <a href="http://dev.mysql.com/doc/refman/5.0/en/show-status.html">SHOW STATUS</a> returned global status values. The default as of 5.0.2 is to return session values, which is incompatible with previous versions. To issue a <a href="http://dev.mysql.com/doc/refman/5.0/en/show-status.html">SHOW STATUS</a> statement that will retrieve global status values for all versions of MySQL, write it like this: </li>
</ul>
<p>· SHOW /*!50002 GLOBAL */ STATUS;</p>
<ul>
<li><b>Incompatible change:</b> User variables are not case sensitive in MySQL 5.0. In MySQL 4.1, SET @x = 0; SET @X = 1; SELECT @x; created two variables and returned 0. In MySQL 5.0, it creates one variable and returns 1. Replication setups that rely on the old behavior may be affected by this change. </li>
<li>Some keywords are reserved in MySQL 5.0 that were not reserved in MySQL 4.1. See <a href="http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html">Section 8.3, “Reserved Words”</a>. </li>
<li>The LOAD DATA FROM MASTER and LOAD TABLE FROM MASTER statements are deprecated. See <a href="http://dev.mysql.com/doc/refman/5.0/en/load-data-from-master.html">Section 12.6.2.2, “LOAD DATA FROM MASTER Syntax”</a>, for recommended alternatives. </li>
<li>As of MySQL 5.0.3, trailing spaces no longer are removed from values stored in <a href="http://dev.mysql.com/doc/refman/5.0/en/char.html">VARCHAR</a> and <a href="http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html">VARBINARY</a> columns. The maximum lengths for <a href="http://dev.mysql.com/doc/refman/5.0/en/char.html">VARCHAR</a> and <a href="http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html">VARBINARY</a> columns in MySQL 5.0.3 and later are 65,535 characters and 65,535 bytes, respectively. </li>
</ul>
<p>When a binary upgrade (filesystem-level copy of data files) to MySQL 5.0 is performed for a table with a <a href="http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html">VARBINARY</a> column, the column is space-padded to the full allowable width of the column. This causes values in <a href="http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html">VARBINARY</a> columns that do not occupy the full width of the column to include extra trailing spaces after the upgrade, which means that the data in the column is different. </p>
<p>In addition, new rows inserted into a table upgraded in this way will be space padded to the full width of the column. </p>
<p>This issue can be resolved as follows: </p>
<ul>
<ol start="start">
<li>For each table containing <a href="http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html">VARBINARY</a> columns, execute the statement </li>
</ol>
</ul>
<p>1. ALTER TABLE <i>table_name</i> ENGINE=<i>engine_name</i>;</p>
<p>where <i>table_name</i> is the name of the table and <i>engine_name</i> is the name of the storage engine currently used by <i>table_name</i>. In other words, if the table named mytable uses the MyISAM storage engine, then you would use this statement: </p>
<p>ALTER TABLE mytable ENGINE=MYISAM;</p>
<p>This rebuilds the table so that it uses the 5.0 <a href="http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html">VARBINARY</a> format. </p>
<ul>
<ol start="start">
<li>Then you must remove all trailing spaces from any <a href="http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html">VARBINARY</a> column values. For each <a href="http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html">VARBINARY</a> column <i>varbinary_column</i>, you should perform the following statement (where <i>table_name</i> is the name of the table containing the <a href="http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html">VARBINARY</a> column): </li>
</ol>
</ul>
<p>3. UPDATE <i>table_name</i> SET <i>varbinary_column</i> = RTRIM(<i>varbinary_column</i>);</p>
<p>This is necessary and safe because trailing spaces are stripped before 5.0.3, meaning that any trailing spaces are erroneous. </p>
<p>This problem does not occur (and thus these two steps are not required) for tables upgraded using the recommended procedure of dumping tables prior to the upgrade and reloading them afterwards. </p>
<p><b>Note</b></p>
<p>If you create a table with new <a href="http://dev.mysql.com/doc/refman/5.0/en/char.html">VARCHAR</a> or <a href="http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html">VARBINARY</a> columns in MySQL 5.0.3 or later, the table will not be usable if you downgrade to a version older than 5.0.3. Dump the table with <a href="http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html"><b>mysqldump</b></a> before downgrading and reload it after downgrading. </p>
<ul>
<li>Comparisons made between <a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html">FLOAT</a> or <a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html">DOUBLE</a> values that happened to work in MySQL 4.1 may not do so in 5.0. Values of these types are imprecise in all MySQL versions, and you are <i>strongly advised</i> to avoid such comparisons as WHERE <i>col_name</i>=<i>some_double</i>, <i>regardless of the MySQL version you are using</i>. See <a href="http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html">Section B.1.5.8, “Problems with Floating-Point Comparisons”</a>. </li>
<li>As of MySQL 5.0.3, <a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html">BIT</a> is a separate data type, not a synonym for TINYINT(1). See <a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html">Section 10.1.1, “Overview of Numeric Types”</a>. </li>
<li>MySQL 5.0.2 adds several SQL modes that allow stricter control over rejecting records that have invalid or missing values. See <a href="http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html">Section 5.1.7, “Server SQL Modes”</a>, and <a href="http://dev.mysql.com/doc/refman/5.0/en/constraint-invalid-data.html">Section 1.7.6.2, “Constraints on Invalid Data”</a>. If you want to enable this control but continue to use MySQL&#8217;s capability for storing incorrect dates such as &#8217;2004-02-31&#8242;, you should start the server with &#8211;sql_mode=&quot;TRADITIONAL,ALLOW_INVALID_DATES&quot;. </li>
<li>As of MySQL 5.0.2, the SCHEMA and SCHEMAS keywords are accepted as synonyms for DATABASE and DATABASES, respectively. (While “schemata” is grammatically correct and even appears in some MySQL 5.0 system database and table names, it cannot be used as a keyword.) </li>
<li>As of MySQL 5.0.25, <a href="http://dev.mysql.com/doc/refman/5.0/en/datetime.html">TIMESTAMP</a> columns that are NOT NULL now are reported that way by <a href="http://dev.mysql.com/doc/refman/5.0/en/show-columns.html">SHOW COLUMNS</a> and INFORMATION_SCHEMA, rather than as NULL. </li>
</ul>
<p><b>C API Changes:</b></p>
<ul>
<li><b>Incompatible change</b>: Because the MySQL 5.0 server has a new implementation of the <a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html">DECIMAL</a> data type, a problem may occur if the server is used by older clients that still are linked against MySQL 4.1 client libraries. If a client uses the binary client/server protocol to execute prepared statements that generate result sets containing numeric values, an error will be raised: &#8216;Using unsupported buffer type: 246&#8242;</li>
</ul>
<p>This error occurs because the 4.1 client libraries do not support the new MYSQL_TYPE_NEWDECIMAL type value added in 5.0. There is no way to disable the new <a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html">DECIMAL</a> data type on the server side. You can avoid the problem by relinking the application with the client libraries from MySQL 5.0. </p>
<ul>
<li><b>Incompatible change</b>: The ER_WARN_DATA_TRUNCATED warning symbol was renamed to WARN_DATA_TRUNCATED in MySQL 5.0.3. </li>
<li>The reconnect flag in the MYSQL structure is set to 0 by <a href="http://dev.mysql.com/doc/refman/5.0/en/mysql-real-connect.html">mysql_real_connect()</a>. Only those client programs which did not explicitly set this flag to 0 or 1 after <a href="http://dev.mysql.com/doc/refman/5.0/en/mysql-real-connect.html">mysql_real_connect()</a> experience a change. Having automatic reconnection enabled by default was considered too dangerous (due to the fact that table locks, temporary tables, user variables, and session variables are lost after reconnection). </li>
</ul>
<p><b>MySQL Enterprise. </b> MySQL Enterprise subscribers will find more information about upgrading in the Knowledge Base articles found at <a href="https://kb.mysql.com/search.php?cat=search&amp;category=41">Upgrading</a>. Access to the MySQL Knowledge Base collection of articles is one of the advantages of subscribing to MySQL Enterprise. For more information, see <a href="http://www.mysql.com/products/enterprise/advisors.html">http://www.mysql.com/products/enterprise/advisors.html</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.server.ruservers.com/2009/01/upgrading-from-mysql-41-to-50/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
