<?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>枫芸志 &#187; MySQL</title>
	<atom:link href="http://witmax.cn/tag/mysql/feed" rel="self" type="application/rss+xml" />
	<link>http://witmax.cn</link>
	<description>记录成长路途上的点滴总结</description>
	<lastBuildDate>Sat, 12 May 2012 04:45:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>【MySQL】修改时区设置</title>
		<link>http://witmax.cn/mysql-modify-time-zone-settings.html</link>
		<comments>http://witmax.cn/mysql-modify-time-zone-settings.html#comments</comments>
		<pubDate>Fri, 30 Dec 2011 10:30:18 +0000</pubDate>
		<dc:creator>晴枫</dc:creator>
				<category><![CDATA[程序开发]]></category>
		<category><![CDATA[软件技巧]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://witmax.cn/?p=1852</guid>
		<description><![CDATA[实践中遇到的一个问题，开发环境的时间数据一切正常，但正式环境数据库中的时间数据与实际相比差了8个小时。根据以往的PHP时区问题经验，断定问题处在MySQL的时区设定上。 用命令行连上去看一下时间，可以确认问题 修改方法： 修改mysql安装目录下的bin/my.ini，增加以下一行配置项 重启mysql，搞定了 p.s. PHP的时区配置项为 PHP代码中可以通过以下代码来设置时区 时区问题是个小问题，但有时候会影响数据展现，所以统一设置一下比较好。<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜您喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-unknown-table-engine-innodb-solution.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-modify-time-zone-settings.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】Query failed: Unknown table engine ‘InnoDb’的解决办法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-charsets-conf-not-found.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-modify-time-zone-settings.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】File ‘c:\mysql\share\charsets\?.conf’ not found (Errcode: 22)的解决方法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-server-has-gone-away.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-modify-time-zone-settings.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL server has gone away的解决方案</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fphp-mysql-list-tables.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-modify-time-zone-settings.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【PHP】获取MySQL数据库里所有表的方法</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>实践中遇到的一个问题，开发环境的时间数据一切正常，但正式环境数据库中的时间数据与实际相比差了8个小时。根据以往的PHP时区问题经验，断定问题处在MySQL的时区设定上。</p>
<p>用命令行连上去看一下时间，可以确认问题</p>
<p><span id="more-1852"></span></p>
<pre class="brush: plain; title: ; notranslate">mysql&gt; show variables like '%time_zone%';
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone |        |
| time_zone        | SYSTEM |
+------------------+--------+
2 rows in set, 1 warning (0.00 sec)

mysql&gt; select now();
+---------------------+
| now()               |
+---------------------+
| 2011-12-30 18:12:25 |
+---------------------+
1 row in set (0.00 sec)</pre>
<p>修改方法：</p>
<p>修改mysql安装目录下的bin/my.ini，增加以下一行配置项</p>
<pre class="brush: plain; title: ; notranslate">default-time-zone       = &quot;+8:00&quot;</pre>
<p>重启mysql，搞定了</p>
<pre class="brush: plain; title: ; notranslate">mysql&gt; show variables like '%time_zone%';
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone |        |
| time_zone        | +08:00 |
+------------------+--------+
2 rows in set, 1 warning (0.00 sec)</pre>
<p>p.s. PHP的时区配置项为</p>
<pre class="brush: plain; title: ; notranslate">date.timezone = &quot;Asia/Shanghai&quot;</pre>
<p>PHP代码中可以通过以下代码来设置时区</p>
<pre class="brush: php; title: ; notranslate">date_default_timezone_set(&quot;Asia/Shanghai&quot;);</pre>
<p>时区问题是个小问题，但有时候会影响数据展现，所以统一设置一下比较好。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜您喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-unknown-table-engine-innodb-solution.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-modify-time-zone-settings.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】Query failed: Unknown table engine ‘InnoDb’的解决办法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-charsets-conf-not-found.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-modify-time-zone-settings.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】File ‘c:\mysql\share\charsets\?.conf’ not found (Errcode: 22)的解决方法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-server-has-gone-away.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-modify-time-zone-settings.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL server has gone away的解决方案</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fphp-mysql-list-tables.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-modify-time-zone-settings.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【PHP】获取MySQL数据库里所有表的方法</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://witmax.cn/mysql-modify-time-zone-settings.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>【PHP】获取MySQL数据库里所有表的方法</title>
		<link>http://witmax.cn/php-mysql-list-tables.html</link>
		<comments>http://witmax.cn/php-mysql-list-tables.html#comments</comments>
		<pubDate>Sun, 03 Apr 2011 07:09:34 +0000</pubDate>
		<dc:creator>晴枫</dc:creator>
				<category><![CDATA[程序开发]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://witmax.cn/?p=1499</guid>
		<description><![CDATA[获取某个MySQL数据库中所有表的PHP代码如下： 但由于mysql_list_tables方法已经过时，运行以上程序时会给出方法过时的提示信息，如下： Deprecated: Function mysql_list_tables() is deprecated in &#8230; on line xxx 一个处理办法是在php.ini中设置error_reporting，不显示方法过时提示信息 另一个方法是使用PHP官方推荐的替代做法： [完毕]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜您喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysqldumper.html&from=http%3A%2F%2Fwitmax.cn%2Fphp-mysql-list-tables.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQLDumper：便捷的MySQL备份、还原、管理工具</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-unknown-table-engine-innodb-solution.html&from=http%3A%2F%2Fwitmax.cn%2Fphp-mysql-list-tables.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】Query failed: Unknown table engine ‘InnoDb’的解决办法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-server-has-gone-away.html&from=http%3A%2F%2Fwitmax.cn%2Fphp-mysql-list-tables.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL server has gone away的解决方案</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-modify-time-zone-settings.html&from=http%3A%2F%2Fwitmax.cn%2Fphp-mysql-list-tables.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】修改时区设置</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>获取某个MySQL数据库中所有表的PHP代码如下：</p>
<pre class="brush: php; title: ; notranslate">function list_tables($database)
{
    $rs = mysql_list_tables($database);
    $tables = array();
    while ($row = mysql_fetch_row($rs)) {
        $tables[] = $row[0];
    }
    mysql_free_result($rs);
    return $tables;
}</pre>
<p>但由于<a href="http://php.ca/manual/en/function.mysql-list-tables.php" target="_blank">mysql_list_tables方法已经过时</a>，运行以上程序时会给出方法过时的提示信息，如下：</p>
<blockquote><p>
<strong>Deprecated</strong>: Function mysql_list_tables() is deprecated in <strong>&#8230;</strong> on line <strong>xxx</strong>
</p></blockquote>
<p><span id="more-1499"></span></p>
<p>一个处理办法是在php.ini中设置error_reporting，不显示方法过时提示信息</p>
<pre class="brush: plain; title: ; notranslate">error_reporting = E_ALL &amp; ~E_NOTICE &amp; ~E_DEPRECATED</pre>
<p> 另一个方法是使用PHP官方推荐的替代做法： </p>
<pre class="brush: php; title: ; notranslate">function list_tables($database)
{
    $rs = mysql_query(&quot;SHOW TABLES FROM $database&quot;);
    $tables = array();
    while ($row = mysql_fetch_row($rs)) {
        $tables[] = $row[0];
    }
    mysql_free_result($rs);
    return $tables;
}</pre>
<p> [完毕]</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜您喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysqldumper.html&from=http%3A%2F%2Fwitmax.cn%2Fphp-mysql-list-tables.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQLDumper：便捷的MySQL备份、还原、管理工具</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-unknown-table-engine-innodb-solution.html&from=http%3A%2F%2Fwitmax.cn%2Fphp-mysql-list-tables.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】Query failed: Unknown table engine ‘InnoDb’的解决办法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-server-has-gone-away.html&from=http%3A%2F%2Fwitmax.cn%2Fphp-mysql-list-tables.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL server has gone away的解决方案</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-modify-time-zone-settings.html&from=http%3A%2F%2Fwitmax.cn%2Fphp-mysql-list-tables.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】修改时区设置</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://witmax.cn/php-mysql-list-tables.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>【SQL】随机读取N条记录（MySQL、SQL Server、Access、Oracle、postgreSQL）</title>
		<link>http://witmax.cn/sql-random-read-records.html</link>
		<comments>http://witmax.cn/sql-random-read-records.html#comments</comments>
		<pubDate>Wed, 24 Mar 2010 14:28:20 +0000</pubDate>
		<dc:creator>晴枫</dc:creator>
				<category><![CDATA[程序开发]]></category>
		<category><![CDATA[Access]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[postgreSQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://witmax.cn/?p=738</guid>
		<description><![CDATA[利用一条SQL语句从数据库Table表中随机获取N条记录，各数据库的SQL语句略有不同，如下： 1、MySql 以上代码效率不高，自己对1000条数据表随机取10条的测试结果为耗时0.125s，有网友推荐改为以下代码效率有大幅提高，耗时为0.005s，不过结果是随机从某个位置开始取N条记录，而不是随机取N条记录，略有差异。详细说明见mysql使用rand随机查询记录效率测试。 2、SQL Server NewID()函数将创建一个 uniqueidentifier 类型的唯一值。 3、Access Rnd(ID) 其中的ID是自动编号字段，可以利用其他任何数值来完成，比如用姓名字段(UserName) 4、Oracle 1）dbms_random包 注：dbms_random包需要手工安装，位于$ORACLE_HOME/rdbms/admin/dbmsrand.sql 可以产生100到200范围的随机数 2）按概率抽取： 例： 取表Table中记录条数的10%条记录 3）sys_guid 5、postgreSQL 参考资料： 1、sql,oracle获取随机记录方法 2、SQL 随机查询<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜您喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fsql-server-2005-backup-different.html&from=http%3A%2F%2Fwitmax.cn%2Fsql-random-read-records.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">SQL Server 2005“备份集中的数据库备份与现有的数据库不同”的解决方案</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Faspnet_checkschemaversion.html&from=http%3A%2F%2Fwitmax.cn%2Fsql-random-read-records.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【SQL】找不到存储过程 'dbo.aspnet_CheckSchemaVersion'的解决办法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fsql-null-order.html&from=http%3A%2F%2Fwitmax.cn%2Fsql-random-read-records.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【SQL】非NULL数据排序提前</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fsql-row-column-exchange.html&from=http%3A%2F%2Fwitmax.cn%2Fsql-random-read-records.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【SQL】行列互换代码实例</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>利用一条SQL语句从数据库Table表中随机获取N条记录，各数据库的SQL语句略有不同，如下：</p>
<p><strong>1、MySql</strong></p>
<pre class="brush: sql; title: ; notranslate">Select * From TABLE Order By Rand() Limit N</pre>
<p>以上代码效率不高，自己对1000条数据表随机取10条的测试结果为耗时0.125s，有网友推荐改为以下代码效率有大幅提高，耗时为0.005s，不过结果是随机从某个位置开始取N条记录，而不是随机取N条记录，略有差异。详细说明见<a href="http://jnote.cn/blog/mysql/mysql-rand-efficiency.html">mysql使用rand随机查询记录效率测试</a>。</p>
<pre class="brush: sql; title: ; notranslate">SELECT * FROM `TABLE` a join (SELECT ROUND(RAND() * ((SELECT MAX(id) FROM `TABLE`)-(SELECT MIN(id) FROM `TABLE`))+(SELECT MIN(id) FROM `TABLE`)) AS id) AS b WHERE a.id &gt;= b.id ORDER BY a.id LIMIT N;</pre>
<p><strong>2、SQL Server</strong></p>
<pre class="brush: sql; title: ; notranslate">Select TOP N * From TABLE Order By NewID()</pre>
<p><span id="more-738"></span></p>
<p>NewID()函数将创建一个 uniqueidentifier 类型的唯一值。</p>
<p><strong>3、Access</strong></p>
<pre class="brush: sql; title: ; notranslate">Select TOP N * From TABLE Order By Rnd(ID)</pre>
<p>Rnd(ID) 其中的ID是自动编号字段，可以利用其他任何数值来完成，比如用姓名字段(UserName)</p>
<pre class="brush: sql; title: ; notranslate">Select TOP N * From TABLE Order BY Rnd(Len(UserName))</pre>
<p><strong>4、Oracle</strong></p>
<p>1）dbms_random包</p>
<pre class="brush: sql; title: ; notranslate">select * from (select * from Table order by dbms_random.value) where rownum &amp;lt; N; </pre>
<p>注：dbms_random包需要手工安装，位于$ORACLE_HOME/rdbms/admin/dbmsrand.sql</p>
<pre class="brush: sql; title: ; notranslate">dbms_random.value(100,200)</pre>
<p>可以产生100到200范围的随机数</p>
<p>2）按概率抽取：</p>
<pre class="brush: sql; title: ; notranslate">select * from Table sample(百分比); </pre>
<p>例：</p>
<pre class="brush: sql; title: ; notranslate">select * from Table sample(10); </pre>
<p>取表Table中记录条数的10%条记录</p>
<p>3）sys_guid</p>
<pre class="brush: sql; title: ; notranslate">select * from (select * from Table orderby   sys_guid()) where rownum&amp;lt;N;</pre>
<p><strong>5、postgreSQL</strong></p>
<pre class="brush: sql; title: ; notranslate">select * from Table order by random() limit N</pre>
<p>参考资料：</p>
<p>1、<a href="http://www.51testing.com/?uid-101545-action-viewspace-itemid-83475">sql,oracle获取随机记录方法</a></p>
<p>2、<a href="http://www.itxuexi.com/tech/shujuku/skill/910981263127250.html">SQL 随机查询</a></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜您喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fsql-server-2005-backup-different.html&from=http%3A%2F%2Fwitmax.cn%2Fsql-random-read-records.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">SQL Server 2005“备份集中的数据库备份与现有的数据库不同”的解决方案</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Faspnet_checkschemaversion.html&from=http%3A%2F%2Fwitmax.cn%2Fsql-random-read-records.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【SQL】找不到存储过程 'dbo.aspnet_CheckSchemaVersion'的解决办法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fsql-null-order.html&from=http%3A%2F%2Fwitmax.cn%2Fsql-random-read-records.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【SQL】非NULL数据排序提前</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fsql-row-column-exchange.html&from=http%3A%2F%2Fwitmax.cn%2Fsql-random-read-records.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【SQL】行列互换代码实例</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://witmax.cn/sql-random-read-records.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>【MySQL】Query failed: Unknown table engine &#8216;InnoDb&#8217;的解决办法</title>
		<link>http://witmax.cn/mysql-unknown-table-engine-innodb-solution.html</link>
		<comments>http://witmax.cn/mysql-unknown-table-engine-innodb-solution.html#comments</comments>
		<pubDate>Sat, 13 Mar 2010 08:52:41 +0000</pubDate>
		<dc:creator>晴枫</dc:creator>
				<category><![CDATA[软件技巧]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://witmax.cn/?p=721</guid>
		<description><![CDATA[今儿个安装在线客服应用Mibew Messenger来玩，安装过程中断，提示了 Query failed: Unknown table engine &#8216;InnoDb&#8217; 提示信息明显，缺少InnoDb数据库引擎。 命令行下查看一下可用数据库引擎： mysql&#62; show engines; +&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212; &#124; Engine     &#124; Support &#124; Comment &#8230; +&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212; &#124; MEMORY     &#124; YES     &#124; &#8230; &#124; FEDERATED  &#124; NO      &#124; &#124; MyISAM     &#124; DEFAULT &#124; &#124; BLACKHOLE  &#124; YES     &#124; [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜您喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-modify-time-zone-settings.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-unknown-table-engine-innodb-solution.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】修改时区设置</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-charsets-conf-not-found.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-unknown-table-engine-innodb-solution.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】File ‘c:\mysql\share\charsets\?.conf’ not found (Errcode: 22)的解决方法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-server-has-gone-away.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-unknown-table-engine-innodb-solution.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL server has gone away的解决方案</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-autobackup.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-unknown-table-engine-innodb-solution.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】批处理实现数据库自动备份</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>今儿个安装在线客服应用Mibew Messenger来玩，安装过程中断，提示了</p>
<blockquote><p>Query failed: Unknown table engine &#8216;InnoDb&#8217;</p></blockquote>
<p>提示信息明显，缺少InnoDb数据库引擎。</p>
<p>命令行下查看一下可用数据库引擎：</p>
<p><span id="more-721"></span></p>
<div id="_mcePaste">
<blockquote>
<div id="_mcePaste">mysql&gt; show engines;</div>
<div id="_mcePaste">+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;</div>
<div id="_mcePaste">| Engine     | Support | Comment &#8230;</div>
<div id="_mcePaste">+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;</div>
<div id="_mcePaste">| MEMORY     | YES     | &#8230;</div>
<div id="_mcePaste">| FEDERATED  | NO      |</div>
<div id="_mcePaste">| MyISAM     | DEFAULT |</div>
<div id="_mcePaste">| BLACKHOLE  | YES     |</div>
<div id="_mcePaste">| MRG_MYISAM | YES     |</div>
<div id="_mcePaste">| CSV        | YES     |</div>
<div id="_mcePaste">| ARCHIVE    | YES     |</div>
<div id="_mcePaste">| InnoDB     | NO      |</div>
<div id="_mcePaste">+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+-</div>
<div id="_mcePaste">8 rows in set (0.00 sec)</div>
</blockquote>
</div>
<p>确实是InnoDB引擎没启用。</p>
<p>解决办法有二：</p>
<p>1、修改SQL语句中的引擎InnoDB为MyISAM，一般MyISAM都是启用的。</p>
<p>2、修改MySQL安装目录下的my.ini，在skip-innodb前增加#，重启MySQL，再次通过命令行查看结果为：</p>
<blockquote>
<div id="_mcePaste">mysql&gt; show engines;</div>
<div id="_mcePaste">+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;</div>
<div id="_mcePaste">| Engine     | Support | Comment &#8230;</div>
<div id="_mcePaste">+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;</div>
<div id="_mcePaste">| MEMORY     | YES     | &#8230;</div>
<div id="_mcePaste">| FEDERATED  | NO      |</div>
<div id="_mcePaste">| MyISAM     | DEFAULT |</div>
<div id="_mcePaste">| BLACKHOLE  | YES     |</div>
<div id="_mcePaste">| MRG_MYISAM | YES     |</div>
<div id="_mcePaste">| CSV        | YES     |</div>
<div id="_mcePaste">| ARCHIVE    | YES     |</div>
<div id="_mcePaste">| InnoDB     | YES      |</div>
<div id="_mcePaste">+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;</div>
</blockquote>
<div>根据my.ini中的提示，启用InnoDB引擎会消耗内存和硬盘空间，如非必要不建议启用。</div>
<div></div>
<div>[完毕]</div>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜您喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-modify-time-zone-settings.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-unknown-table-engine-innodb-solution.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】修改时区设置</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-charsets-conf-not-found.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-unknown-table-engine-innodb-solution.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】File ‘c:\mysql\share\charsets\?.conf’ not found (Errcode: 22)的解决方法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-server-has-gone-away.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-unknown-table-engine-innodb-solution.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL server has gone away的解决方案</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-autobackup.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-unknown-table-engine-innodb-solution.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】批处理实现数据库自动备份</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://witmax.cn/mysql-unknown-table-engine-innodb-solution.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>【MySQL】File &#8216;c:\mysql\share\charsets\?.conf&#8217; not found (Errcode: 22)的解决方法</title>
		<link>http://witmax.cn/mysql-charsets-conf-not-found.html</link>
		<comments>http://witmax.cn/mysql-charsets-conf-not-found.html#comments</comments>
		<pubDate>Wed, 10 Mar 2010 13:17:14 +0000</pubDate>
		<dc:creator>晴枫</dc:creator>
				<category><![CDATA[软件技巧]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://witmax.cn/?p=718</guid>
		<description><![CDATA[PHP 4.4.1+MySQL 5.1的环境下出现了如下的提示： File &#8216;c:\mysql\share\charsets\?.conf&#8217; not found (Errcode: 22) Character set &#8216;#33&#8242; is not a compiled character set and is not specified in the &#8216;c:\mysql\share\charsets\Index&#8217; file 查阅一番后基本可以确定原因为低版本的PHP和高版本的MySQL之间的兼容性导致的。 最简单的办法是升级PHP到PHP5.3版本即可搞定，未知测试。因服务器不是我配的，不敢乱动，怕搞出麻烦，于是保留低版本的PHP，另寻其他方法。 以下试验了多种网络上查到的解决方法，供大家参考： 有说是MySQL的配置中basedir没设好，检查了一下MySQL安装目录下的my.ini，basedir正确，不是这个原因。 有说把MySQL的配置my.ini中的default-character-set=utf8前面加#注释掉就搞定的，我改了，无效。 有说把MySQL安装目录\share\charsets目录下的所有文件复制到c:\mysql\share\charsets\下的，我复制了，一样无效。 最后找到一种方法，把PHP.ini中的output_buffering = Off 改为 output_buffering = On，上面的提示不见了，搞定。 知其然，不知其所以然。哪位大虾知道的，烦请告知，小弟谢过！<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜您喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-server-has-gone-away.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-charsets-conf-not-found.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL server has gone away的解决方案</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-autobackup.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-charsets-conf-not-found.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】批处理实现数据库自动备份</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-modify-time-zone-settings.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-charsets-conf-not-found.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】修改时区设置</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-unknown-table-engine-innodb-solution.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-charsets-conf-not-found.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】Query failed: Unknown table engine ‘InnoDb’的解决办法</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>PHP 4.4.1+MySQL 5.1的环境下出现了如下的提示：</p>
<blockquote><p>File &#8216;c:\mysql\share\charsets\?.conf&#8217; not found (Errcode: 22) Character set &#8216;#33&#8242; is not a compiled character set and is not specified in the &#8216;c:\mysql\share\charsets\Index&#8217; file</p></blockquote>
<p>查阅一番后基本可以确定原因为低版本的PHP和高版本的MySQL之间的兼容性导致的。</p>
<p>最简单的办法是升级PHP到PHP5.3版本即可搞定，未知测试。因服务器不是我配的，不敢乱动，怕搞出麻烦，于是保留低版本的PHP，另寻其他方法。</p>
<p>以下试验了多种网络上查到的解决方法，供大家参考：</p>
<p><span id="more-718"></span></p>
<p>有说是MySQL的配置中basedir没设好，检查了一下MySQL安装目录下的my.ini，basedir正确，不是这个原因。</p>
<p>有说把MySQL的配置my.ini中的default-character-set=utf8前面加#注释掉就搞定的，我改了，无效。</p>
<p>有说把MySQL安装目录\share\charsets目录下的所有文件复制到c:\mysql\share\charsets\下的，我复制了，一样无效。</p>
<p>最后找到一种方法，把PHP.ini中的output_buffering = Off 改为 output_buffering = On，上面的提示不见了，搞定。</p>
<p>知其然，不知其所以然。哪位大虾知道的，烦请告知，小弟谢过！</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜您喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-server-has-gone-away.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-charsets-conf-not-found.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL server has gone away的解决方案</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-autobackup.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-charsets-conf-not-found.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】批处理实现数据库自动备份</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-modify-time-zone-settings.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-charsets-conf-not-found.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】修改时区设置</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-unknown-table-engine-innodb-solution.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-charsets-conf-not-found.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】Query failed: Unknown table engine ‘InnoDb’的解决办法</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://witmax.cn/mysql-charsets-conf-not-found.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>【MySQL】批处理实现数据库自动备份</title>
		<link>http://witmax.cn/mysql-autobackup.html</link>
		<comments>http://witmax.cn/mysql-autobackup.html#comments</comments>
		<pubDate>Wed, 21 Oct 2009 12:44:24 +0000</pubDate>
		<dc:creator>晴枫</dc:creator>
				<category><![CDATA[软件技巧]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[批处理]]></category>

		<guid isPermaLink="false">http://witmax.cn/?p=529</guid>
		<description><![CDATA[数据库自动备份是常见任务，为了数据的安全性和可恢复性，这个也是必须的。数据是网站之本，一旦出现意外情况，自然需要还原。 前面曾介绍过一款叫 MySQLDumper 的工具，但MySQLDumper无法实现自动备份，于是考虑了用Windows的计划任务+批处理来实现MySQL数据库的自动备份。 操作步骤如下： 1、建立批处理程序文件data_backup.cmd，输入以下两行命令即可。 第一行命令为备份数据库uchome为 日期_uchome.sql 数据文件。mysqldump参数含义罗列如下： &#8211;default-character-set 数据库使用的编码 &#8211;skip-lock-tables 忽略锁定的表格 -h 主机名 -P 端口号 -u 用户名 -p 密码 更多参数可以通过 mysqldump &#8211;help 查看。 第二行命令为删除7天以前的备份文件。forfiles参数含义罗列如下： /d [{+ &#124; -}] [{MM/DD/YYYY &#124; DD}]   选择日期大于或等于 (+)（或者小于或等于 (-)）指定日期的文件，其中 MM/DD/YYYY 是指定的日期，DD 是当前日期增加 DD 天。如果未指定 + 或 -，则使用 +。DD 的有效范围是 0 &#8211; 32768。 /m SearchMask  按照 SearchMask 搜索文件。默认的 SearchMask [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜您喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-unknown-table-engine-innodb-solution.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-autobackup.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】Query failed: Unknown table engine ‘InnoDb’的解决办法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-server-has-gone-away.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-autobackup.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL server has gone away的解决方案</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-modify-time-zone-settings.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-autobackup.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】修改时区设置</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysqldumper.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-autobackup.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQLDumper：便捷的MySQL备份、还原、管理工具</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>数据库自动备份是常见任务，为了数据的安全性和可恢复性，这个也是必须的。数据是网站之本，一旦出现意外情况，自然需要还原。</p>
<p>前面曾介绍过一款叫 <a href="http://witmax.cn/mysqldumper.html">MySQLDumper</a> 的工具，但MySQLDumper无法实现自动备份，于是考虑了用Windows的计划任务+批处理来实现MySQL数据库的自动备份。</p>
<p><span id="more-529"></span></p>
<p>操作步骤如下：</p>
<p>1、建立批处理程序文件data_backup.cmd，输入以下两行命令即可。</p>
<pre class="brush: plain; title: ; notranslate">mysqldump --default-character-set=utf8 --skip-lock-tables -hlocalhost -P3306 -uusername -ppassword uchome &gt; %date:~0,10%_uchome.sql
forfiles /d -7 /m *.sql /c &quot;cmd /c del /f @file&quot;</pre>
<p>第一行命令为备份数据库uchome为 日期_uchome.sql 数据文件。mysqldump参数含义罗列如下：</p>
<ul>
<li>&#8211;default-character-set 数据库使用的编码</li>
<li>&#8211;skip-lock-tables 忽略锁定的表格</li>
<li>-h 主机名</li>
<li>-P 端口号</li>
<li>-u 用户名</li>
<li>-p 密码</li>
<li>更多参数可以通过 mysqldump &#8211;help 查看。</li>
</ul>
<p>第二行命令为删除7天以前的备份文件。forfiles参数含义罗列如下：</p>
<ul>
<li><strong>/</strong>d [{<strong>+ </strong>| <strong>-</strong>}] [{<em>MM</em><strong>/</strong><em>DD</em><strong>/</strong><em>YYYY </em>| <em>DD</em>}]   选择日期大于或等于 (<strong>+</strong>)（或者小于或等于 (<strong>-</strong>)）指定日期的文件，其中 <em>MM</em><strong>/</strong><em>DD</em><strong>/</strong><em>YYYY</em> 是指定的日期，<em>DD</em> 是当前日期增加 <em>DD</em> 天。如果未指定 <strong>+</strong> 或 <strong>-</strong>，则使用 <strong>+</strong>。<em>DD</em> 的有效范围是 0 &#8211; 32768。</li>
<li>/m SearchMask  按照 <em>SearchMask</em> 搜索文件。默认的 <em>SearchMask</em> 是 <strong>*.*</strong>。</li>
<li>/c Command  在每个文件上运行指定的 Command。带有空格的命令字符串必须用引号括起来。默认的 Command 是 “cmd /c echo @file”。</li>
<li>@file 指代文件名</li>
<li>更多参数可以通过 forfiles/? 查看。</li>
</ul>
<p><em>注：forfiles命令为Windows 2003上的命令， XP上没有这个命令。</em></p>
<p>2、添加计划任务，将刚建立的批处理文件data_backup.cmd按每天一起运行一遍。考虑到备份的稳定和不影响系统，一般安排在凌晨执行备份。</p>
<p>经过如此配置，便实现了每天对MySQL数据库执行备份，且只保留7天内的备份。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜您喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-unknown-table-engine-innodb-solution.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-autobackup.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】Query failed: Unknown table engine ‘InnoDb’的解决办法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-server-has-gone-away.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-autobackup.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL server has gone away的解决方案</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-modify-time-zone-settings.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-autobackup.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】修改时区设置</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysqldumper.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-autobackup.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQLDumper：便捷的MySQL备份、还原、管理工具</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://witmax.cn/mysql-autobackup.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>MySQLDumper：便捷的MySQL备份、还原、管理工具</title>
		<link>http://witmax.cn/mysqldumper.html</link>
		<comments>http://witmax.cn/mysqldumper.html#comments</comments>
		<pubDate>Fri, 11 Sep 2009 03:34:31 +0000</pubDate>
		<dc:creator>晴枫</dc:creator>
				<category><![CDATA[程序开发]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[开源]]></category>

		<guid isPermaLink="false">http://witmax.cn/?p=266</guid>
		<description><![CDATA[MySQLDumper是一个备份和恢复MySQL数据库的PHP管理脚本，使用上简单便捷。主要用于使用免费空间及共享主机等不能直接操作服务器的用户管理MySQL数据库。如果你能直接操作服务器，那么使用mysqldump命令效率会更高且更方便。 相对PHPMyAdmin来说，其对数据库的管理能力并没有那么强。但术业有专攻，MySQLDumper专长在MySQL的数据备份和还原。只需点几下鼠标便可实现对数据库的备份和还原，相对PHPMyAdmin来说操作便捷，反应要快。 MySQLDumper的设计初衷是为了解决绝大部分空间上PHP文件执行时间不能超过30秒而导致的大数据库难以备份、大数据库下载速度太慢和下载容易中断等问题，因而对大数据库的备份还原操作有比较好的支持，采用了AJAX技术，使得进度显示更加直观，不像PHPMyAdmin会直接死在那里知道备份完成。 做了一个测试，备份包括13 个表/630885 条数据/20.66 MB大小的数据库，用时1分钟19秒，压缩后备份为3.60MB，如下图所示： 备份已完成，如下图： MySQLDumper特性： 支持FTP自动传送备份文件到远程服务器，最多可以设置三个远程服务器 E-mail备份，可以把备份好的数据库通过邮件发送到你的邮箱中(默认不开启) 支持备份的Gzip压缩，使备份文件更小 支持还原Gzip压缩文件，节省带宽 保留多个备份，可设定数量上限，超过后删除旧备份(默认不开启) 使用.htaccess文件来实现访问限定，无内置的认证系统，如服务器不支持.htaccess那么不推荐用MySQLDumper 记录操作日志，可方便查看 源码下载：http://sourceforge.net/projects/mysqldumper/files/ 官方网站： http://www.mysqldumper.de/<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜您喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fphp-mysql-list-tables.html&from=http%3A%2F%2Fwitmax.cn%2Fmysqldumper.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【PHP】获取MySQL数据库里所有表的方法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-modify-time-zone-settings.html&from=http%3A%2F%2Fwitmax.cn%2Fmysqldumper.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】修改时区设置</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-unknown-table-engine-innodb-solution.html&from=http%3A%2F%2Fwitmax.cn%2Fmysqldumper.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】Query failed: Unknown table engine ‘InnoDb’的解决办法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-server-has-gone-away.html&from=http%3A%2F%2Fwitmax.cn%2Fmysqldumper.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL server has gone away的解决方案</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>MySQLDumper是一个备份和恢复MySQL数据库的PHP管理脚本，使用上简单便捷。主要用于使用免费空间及共享主机等不能直接操作服务器的用户管理MySQL数据库。如果你能直接操作服务器，那么使用mysqldump命令效率会更高且更方便。</p>
<p><span id="more-266"></span></p>
<p><div class="wp-caption aligncenter" style="width: 570px"><a title="MySQLDumper备份界面" rel="lightbox[mysqldumper]" href="http://witmax.cn/img/mysqldumper.png"><img title="MySQLDumper备份界面" src="http://witmax.cn/img/mysqldumper.png" alt="MySQLDumper备份界面" width="560" /></a><p class="wp-caption-text">MySQLDumper备份界面</p></div>相对PHPMyAdmin来说，其对数据库的管理能力并没有那么强。但术业有专攻，MySQLDumper专长在MySQL的数据备份和还原。只需点几下鼠标便可实现对数据库的备份和还原，相对PHPMyAdmin来说操作便捷，反应要快。</p>
<p>MySQLDumper的设计初衷是为了解决绝大部分空间上PHP文件执行时间不能超过30秒而导致的大数据库难以备份、大数据库下载速度太慢和下载容易中断等问题，因而对大数据库的备份还原操作有比较好的支持，采用了AJAX技术，使得进度显示更加直观，不像PHPMyAdmin会直接死在那里知道备份完成。</p>
<p>做了一个测试，备份包括13 个表/630885 条数据/20.66 MB大小的数据库，用时1分钟19秒，压缩后备份为3.60MB，如下图所示：</p>
<div class="wp-caption aligncenter" style="width: 570px"><a title="MySQLDumper备份执行中界面" rel="lightbox[mysqldumper]" href="http://witmax.cn/img/mysqldumper-backup.png"><img title="MySQLDumper备份执行中界面" src="http://witmax.cn/img/mysqldumper-backup.png" alt="MySQLDumper备份执行中界面" width="560" /></a><p class="wp-caption-text">MySQLDumper备份执行中界面</p></div>
<p>备份已完成，如下图：</p>
<div class="wp-caption aligncenter" style="width: 570px"><a title="MySQLDumper备份完成界面" rel="lightbox[mysqldumper]" href="http://witmax.cn/img/mysqldumper-done.png"><img title="MySQLDumper备份完成界面" src="http://witmax.cn/img/mysqldumper-done.png" alt="MySQLDumper备份完成界面行中界面" width="560" /></a><p class="wp-caption-text">MySQLDumper备份完成界面</p></div>
<p>MySQLDumper特性：</p>
<ul>
<li>
<ul>
<li>支持FTP自动传送备份文件到远程服务器，最多可以设置三个远程服务器</li>
<li>E-mail备份，可以把备份好的数据库通过邮件发送到你的邮箱中(默认不开启)</li>
<li>支持备份的Gzip压缩，使备份文件更小</li>
<li>支持还原Gzip压缩文件，节省带宽</li>
<li>保留多个备份，可设定数量上限，超过后删除旧备份(默认不开启)</li>
<li>使用.htaccess文件来实现访问限定，无内置的认证系统，如<strong>服务器不支持.htaccess那么不推荐用MySQLDumper</strong></li>
<li>记录操作日志，可方便查看</li>
</ul>
</li>
</ul>
<p>源码下载：<a href="http://sourceforge.net/projects/mysqldumper/files/">http://sourceforge.net/projects/mysqldumper/files/</a></p>
<p>官方网站：<strong> </strong><a href="http://www.mysqldumper.de/">http://www.mysqldumper.de/</a></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜您喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fphp-mysql-list-tables.html&from=http%3A%2F%2Fwitmax.cn%2Fmysqldumper.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【PHP】获取MySQL数据库里所有表的方法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-modify-time-zone-settings.html&from=http%3A%2F%2Fwitmax.cn%2Fmysqldumper.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】修改时区设置</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-unknown-table-engine-innodb-solution.html&from=http%3A%2F%2Fwitmax.cn%2Fmysqldumper.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】Query failed: Unknown table engine ‘InnoDb’的解决办法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-server-has-gone-away.html&from=http%3A%2F%2Fwitmax.cn%2Fmysqldumper.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">MySQL server has gone away的解决方案</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://witmax.cn/mysqldumper.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL server has gone away的解决方案</title>
		<link>http://witmax.cn/mysql-server-has-gone-away.html</link>
		<comments>http://witmax.cn/mysql-server-has-gone-away.html#comments</comments>
		<pubDate>Fri, 14 Aug 2009 10:04:41 +0000</pubDate>
		<dc:creator>晴枫</dc:creator>
				<category><![CDATA[软件技巧]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://witmax.cn/?p=85</guid>
		<description><![CDATA[症状： 使用命令行对MySQL数据库进行还原时出现错误提示： ERROR 2006 (HY000) at line 22: MySQL server has gone away 分析： 可能是因为其中一些insert语句的大小超出了MySQL目前设置的缓冲区大小。 解决方案： 在MySQL安装目录，找到my.ini文件(Linux下位/etc/my.cnf)，在[mysqld]行后添加 #最大允许的传输数据包大小，默认为1M max_allowed_packet = 32M max_allowed_packet 参数的作用是，用来控制其通信缓冲区的最大长度。<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜您喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-modify-time-zone-settings.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-server-has-gone-away.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】修改时区设置</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-charsets-conf-not-found.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-server-has-gone-away.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】File ‘c:\mysql\share\charsets\?.conf’ not found (Errcode: 22)的解决方法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-unknown-table-engine-innodb-solution.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-server-has-gone-away.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】Query failed: Unknown table engine ‘InnoDb’的解决办法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fphp-mysql-list-tables.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-server-has-gone-away.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【PHP】获取MySQL数据库里所有表的方法</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p><strong>症状：</strong></p>
<p>使用命令行对MySQL数据库进行还原时出现错误提示：</p>
<blockquote><p>ERROR 2006 (HY000) at line 22: MySQL server has gone away</p></blockquote>
<p><strong>分析：</strong></p>
<p>可能是因为其中一些insert语句的大小超出了MySQL目前设置的缓冲区大小。</p>
<p><strong><span id="more-85"></span>解决方案：</strong></p>
<p><span>在MySQL安装目录，找到my.ini文件(Linux下位</span>/etc/my.cnf<span>)，在</span>[mysqld]行后添加</p>
<blockquote><p>#最大允许的传输数据包大小，默认为1M</p>
<p><span> max_allowed_packet = 32M</span></p></blockquote>
<p><span>max_allowed_packet 参数的作用是，用来控制其通信缓冲区的最大长度。 </span></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">猜您喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-modify-time-zone-settings.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-server-has-gone-away.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】修改时区设置</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-charsets-conf-not-found.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-server-has-gone-away.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】File ‘c:\mysql\share\charsets\?.conf’ not found (Errcode: 22)的解决方法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fmysql-unknown-table-engine-innodb-solution.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-server-has-gone-away.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【MySQL】Query failed: Unknown table engine ‘InnoDb’的解决办法</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwitmax.cn%2Fphp-mysql-list-tables.html&from=http%3A%2F%2Fwitmax.cn%2Fmysql-server-has-gone-away.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">【PHP】获取MySQL数据库里所有表的方法</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://witmax.cn/mysql-server-has-gone-away.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

