<?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>FACE OF ADVERSITY - My Posture &#187; mysql</title>
	<atom:link href="http://www.lidecheng.com/blog/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lidecheng.com/blog</link>
	<description>直面困境 - lidecheng&#039;s weblog</description>
	<lastBuildDate>Thu, 17 Jun 2010 05:38:35 +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>phpmyadmin导入大数据的方法</title>
		<link>http://www.lidecheng.com/blog/phpmyadmin-import-excessive-sql-file/</link>
		<comments>http://www.lidecheng.com/blog/phpmyadmin-import-excessive-sql-file/#comments</comments>
		<pubDate>Sun, 03 May 2009 06:07:35 +0000</pubDate>
		<dc:creator>lidecheng</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[phpmyadmin]]></category>

		<guid isPermaLink="false">http://www.lidecheng.com/blog/?p=144</guid>
		<description><![CDATA[在使用PhpMyAdmin的时候经常用到数据的导入和导出(Export/Import)，但是在导入大数据的时候由于php上传文件的限制和脚本响应时间的限制，导致phpMyAdmin无法导入大数据，对于导入大数据到mysql的，我以前使用过使用SHELL的方式导入几百兆的文件到mySQL数据库（原文），但是国内的虚拟主机绝大多数不像DreamHost一样开放SHELL权限，而且多数都是Windows Server服务器。我们自己又没有权限修改php.ini文件，对于这种情况我们可以使用phpMyAdmin提供的$cfg['UploadDir']方法，导入服务器上存在的.sql文件。
首先，找到phpMyAdmin的目录，找到根目录下的config.inc.php文件，然后找到 $cfg['UploadDir'] ，通过注释(Directories for saving/loading files from server)就可以看出这是用来导入服务器上的SQL文件的方法。相对的就是 $cfg['SaveDir'] ，顾名思义就是把导出的SQL文件保存在服务器上的目录中。
<span class="readmore"><a href="http://www.lidecheng.com/blog/phpmyadmin-import-excessive-sql-file/" title="phpmyadmin导入大数据的方法">Read the full story &#187;</a></span>]]></description>
			<content:encoded><![CDATA[<p>在使用PhpMyAdmin的时候经常用到数据的导入和导出(Export/Import)，但是在导入大数据的时候由于php上传文件的限制和脚本响应时间的限制，导致phpMyAdmin无法导入大数据，对于导入大数据到mysql的，我以前使用过使用SHELL的方式导入几百兆的文件到mySQL数据库（<a href="http://www.lidecheng.com/blog/ssh-wget-input-large-sql-file/" title="利用SSH导入大数据到mysql的快捷方法">原文</a>），但是国内的虚拟主机绝大多数不像DreamHost一样开放SHELL权限，而且多数都是Windows Server服务器。我们自己又没有权限修改php.ini文件，对于这种情况我们可以使用phpMyAdmin提供的<strong>$cfg['UploadDir']</strong>方法，导入服务器上存在的.sql文件。</p>
<p>首先，找到phpMyAdmin的目录，找到根目录下的config.inc.php文件，然后找到 <strong>$cfg['UploadDir']</strong> ，通过注释(Directories for saving/loading files from server)就可以看出这是用来导入服务器上的SQL文件的方法。相对的就是 <strong>$cfg['SaveDir']</strong> ，顾名思义就是把导出的SQL文件保存在服务器上的目录中。</p>
<p>修改这个参数</p>
<blockquote><p>
$cfg['UploadDir'] = 'ImportSQLFile';<br />
$cfg['SaveDir'] = 'ExportSQLFile';
</p></blockquote>
<p>然后在phpMyAdmin中建立两个文件夹，ImportSQLFile和ExportSQLFile，一个用作大数据的导入，一个用作数据导出备份。</p>
<p>然后把我们需要导入的sql文件复制到ImportSQLFile中，上传到服务器上，选择需要导入的数据库名，选择导入(Import)，就会发现在<strong>文件导入(File to import)</strong>的地方多出来一个<strong>导入服务器上的SQL文件(web server upload directory)</strong></p>
<p><a href="http://www.lidecheng.com/uploads/2009/05/phpmyadminImportSQLFile.jpg"><img src="http://www.lidecheng.com/uploads/2009/05/phpmyadminImportSQLFile.jpg" alt="phpmyadmin在服务器上导入大数据" /></a></p>
<p>通过这种方法可以突破php.ini的上传文件限制，极限我没有试过，我上传的10M .sql文件成功导入到mysql中。</p>
<p>同理在导出/备份mysql数据的时候也可以直接保存在服务器上，保存到<strong>$cfg['SaveDir'] = 'ExportSQLFile';</strong>中指定的文件夹中</p>
<p><a href="http://www.lidecheng.com/uploads/2009/05/phpmyadminExportSQLFile.jpg"><img src="http://www.lidecheng.com/uploads/2009/05/phpmyadminExportSQLFile.jpg" alt="phpmyadmin在服务器上备份数据" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lidecheng.com/blog/phpmyadmin-import-excessive-sql-file/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>解决关于php读取mysql里中文出现乱码的问题</title>
		<link>http://www.lidecheng.com/blog/php-query-mysql-zh-characters/</link>
		<comments>http://www.lidecheng.com/blog/php-query-mysql-zh-characters/#comments</comments>
		<pubDate>Tue, 26 Aug 2008 20:53:02 +0000</pubDate>
		<dc:creator>lidecheng</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.lidecheng.com/blog/?p=24</guid>
		<description><![CDATA[今天用php+mysql做一个Project遇到了中文乱码问题。下图(几个???应该是中文显示区域)：

这种问题在开发时候是常见的，当然是mysql字符与html中header头文件上指定的字符集不统一引起的，以前也遇到过这个问题，当时采用的方法是在打开MySQL服务器连接的后面，链接数据库的前面加入转换mysql字符集的方法：
mysql_query("set names 'gbk'");
<span class="readmore"><a href="http://www.lidecheng.com/blog/php-query-mysql-zh-characters/" title="解决关于php读取mysql里中文出现乱码的问题">Read the full story &#187;</a></span>]]></description>
			<content:encoded><![CDATA[<p>今天用php+mysql做一个Project遇到了中文乱码问题。下图(几个???应该是中文显示区域)：<br />
<img src="http://www.lidecheng.com/uploads/2008/08/zh_characters_error.jpg" alt="php读取mysql中文字符集错误" /></p>
<p>这种问题在开发时候是常见的，当然是mysql字符与html中header头文件上指定的<strong>字符集不统一</strong>引起的，以前也遇到过这个问题，当时采用的方法是在<span style="color: red;">打开MySQL服务器连接的后面</span>，<span style="color: red;">链接数据库的前面</span>加入转换mysql字符集的方法：</p>
<blockquote><p><span style="color: red;">mysql_query("set names '<strong>gbk</strong>'");</span></p></blockquote>
<p>把从mysql中读出来的数据转换为gbk字符集，head中的设置自然是</p>
<blockquote><p>&lt;meta http-equiv="Content-Type" content="text/html; charset=<strong>gbk</strong>" /&gt;</p></blockquote>
<p>今天的问题是我的页面使用的utf-8的字符集，而在我使用转换语句mysql_query("set names 'utf-8'");的时候无效，又不想因为字符集的问题而改变所有页面的charset。</p>
<p>解决方法如下，修<em>set names</em>语句为：</p>
<blockquote><p><span style="color: red;">mysql_query("SET character_set_connection=uft-8 , character_set_results=utf-8, character_set_client=binary, sql_mode='' ");</span></p></blockquote>
<p>即可在字符集为utf-8的网页中正确的读取/显示中文字符了。</p>
<p><img src="http://www.lidecheng.com/uploads/2008/08/zh_characters_okay.jpg" alt="php读取mysql中文字符集错误修正" /></p>
<p>为了更清楚的说明我的方法，贴我的connection中一段代码出来，注意转换字符集语句的放置位置。</p>
<blockquote><p>require 'includes/config.php';</p>
<p>//打开MySQL服务器连接<br />
$connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS);<br />
if (!$connection){<br />
die("Database connection failed:" . mysql_error());<br />
}</p>
<p>//修改字符集<br />
mysql_query("SET character_set_connection=uft-8 , character_set_results=utf-8, character_set_client=binary, sql_mode=''");</p>
<p>//链接数据库<br />
$db_select = mysql_select_db(DB_NAME,$connection);<br />
if(!$db_select){<br />
die("Database selection failed:" . mysql_error());<br />
}</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.lidecheng.com/blog/php-query-mysql-zh-characters/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
