<?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>Digital Memo &#187; MySQL</title>
	<atom:link href="http://digitalmemo.neobie.net/category/database/mysql-database/feed/" rel="self" type="application/rss+xml" />
	<link>http://digitalmemo.neobie.net</link>
	<description>All begin with 0 &#38; 1</description>
	<lastBuildDate>Tue, 06 Jul 2010 07:58:42 +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>Import large database in remote server</title>
		<link>http://digitalmemo.neobie.net/2010/01/10/import-large-database-in-remote-server/</link>
		<comments>http://digitalmemo.neobie.net/2010/01/10/import-large-database-in-remote-server/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 03:56:17 +0000</pubDate>
		<dc:creator>neobie</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[bigdump]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[import]]></category>

		<guid isPermaLink="false">http://digitalmemo.neobie.net/?p=354</guid>
		<description><![CDATA[If you owned slow internet connection, it would be headache if you have large database to be imported in a remote server. Either you import the database through MySQL GUI or phpMyAdmin, the execution time is mostly will exceed the maximum execution time allowed, resulting in an script timeout problem. It would be same if [...]]]></description>
			<content:encoded><![CDATA[<p>If you owned slow internet connection, it would be headache if you have large database to be imported in a remote server. Either you import the database through MySQL GUI or phpMyAdmin, the execution time is mostly will exceed the maximum execution time allowed, resulting in an script timeout problem. It would be same if you manually paste the queries and execute it in remote server. The server simply doesn&#8217;t have enough time to capture your bulk records of &#8220;INSERT&#8221;.</p>
<p>So is there another alternative?</p>
<p>Actually, it is. You can upload your sql file to your remote server, and then use the PHP script to parse the sql file and then run the query line by line.</p>
<p>Fortunately, there is an open source code which ease our job to write our own script. You may visit &#8220;<a href="http://www.ozerov.de/bigdump.php">BigDump</a>&#8220;, and download its source code, <em>bigdump.php</em>, which is zipped as  archive sized at only 10KB zip archive.</p>
<p>Before using BigDump, you need to upload your sql file into your remote server. Be sure not to upload your file to somewhere people may access it, such as your <em>/public_html</em> folder. Normally, you would upload the file at the parent folder of <em>/public_html</em>, such as,<strong><span style="color: #000000;"> </span></strong><span style="color: #000000;"><em>/home/&lt;username&gt;/</em></span></p>
<p><span style="color: #000000;">Bigdump also allow import the records from CSV file. You may refer the following configuration source code, foundat the beginning of bigdump.php.</span></p>
<p><span style="color: #000000;"><br />
</span>
<pre class="brush: php;">
// Database configuration

$db_server   = 'localhost';
$db_name     = '';
$db_username = '';
$db_password = '';

// Other settings (optional)

$filename           = '';     // Specify the dump filename to suppress the file selection dialog
$csv_insert_table   = '';     // Destination table for CSV files
$csv_preempty_table = false;  // true: delete all entries from table specified in $csv_insert_table before processing
$ajax               = true;   // AJAX mode: import will be done without refreshing the website
$linespersession    = 3000;   // Lines to be executed per one import session
$delaypersession    = 0;      // You can specify a sleep time in milliseconds after each session
// Works only if JavaScript is activated. Use to reduce server overrun

// Allowed comment delimiters: lines starting with these strings will be dropped by BigDump

$comment[]='#';                       // Standard comment lines are dropped by default
$comment[]='-- ';
// $comment[]='---';                  // Uncomment this line if using proprietary dump created by outdated mysqldump
// $comment[]='CREATE DATABASE';      // Uncomment this line if your dump contains create database queries in order to ignore them
$comment[]='/*!';                  // Or add your own string to leave out other proprietary things
// Connection character set should be the same as the dump file character set (utf8, latin1, cp1251, koi8r etc.)
// See http://dev.mysql.com/doc/refman/5.0/en/charset-charsets.html for the full list

$db_connection_charset = '';
</pre>
<p><a href="http://www.ozerov.de/bigdump.php">Visit BigDump Official Website!</a></p>
<div class='wp_likes' id='wp_likes_post-354'><a class='like' href="javascript:wp_likes.like(354);" title='' ><img src="http://digitalmemo.neobie.net/wp-content/plugins/wp-likes/images/like.png" alt='' border='0'/>Like</a><span class='text'></span>
<div class='unlike'><a href="javascript:wp_likes.unlike(354);">Unlike</a></div>
</div>
<div id="crp_related"><h3>Posts which might interest you:</h3><ul><li><a href="http://digitalmemo.neobie.net/2009/03/13/php-variable-performance/" rel="bookmark" class="crp_title">PHP variable performance</a></li><li><a href="http://digitalmemo.neobie.net/2009/03/04/mysql-default-sql-mode/" rel="bookmark" class="crp_title">MySQL Default SQL-Mode</a></li><li><a href="http://digitalmemo.neobie.net/2009/02/23/using-proxy-for-faster-surfing-speed/" rel="bookmark" class="crp_title">Using Proxy for faster surfing speed</a></li><li><a href="http://digitalmemo.neobie.net/2009/02/17/screenprint32-v35/" rel="bookmark" class="crp_title">ScreenPrint32 v3.5</a></li><li><a href="http://digitalmemo.neobie.net/2010/03/31/install-red5-application-behind-firewall/" rel="bookmark" class="crp_title">Install Red5 application behind firewall</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div><img src="http://digitalmemo.neobie.net/wp-content/plugins/pixelstats/trackingpixel.php?post_id=354&amp;ts=1280435666" style="display:none;" alt="pixelstats trackingpixel"/>]]></content:encoded>
			<wfw:commentRss>http://digitalmemo.neobie.net/2010/01/10/import-large-database-in-remote-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>INSERT/UPDATE using existing table/row Value</title>
		<link>http://digitalmemo.neobie.net/2009/03/19/insertupdate-using-existing-tablerow-value/</link>
		<comments>http://digitalmemo.neobie.net/2009/03/19/insertupdate-using-existing-tablerow-value/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 03:19:29 +0000</pubDate>
		<dc:creator>neobie</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[existing]]></category>
		<category><![CDATA[insert]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[value]]></category>

		<guid isPermaLink="false">http://digitalmemo.neobie.net/?p=108</guid>
		<description><![CDATA[There is a table &#8216;user&#8217; with score. Simple enough. id username score 10 neobie 530000 INSERT STATEMENT In my application I need to add another user with username &#8216;neobie_2&#8242; and score of 1000 less than user &#8216;neobie&#8217;. I would use INSERT INTO user (username, score) VALUES (&#8216;neobie_2&#8242;, (SELECT score-1000 FROM user WHERE username = &#8216;neobie&#8217;)); [...]]]></description>
			<content:encoded><![CDATA[<p>There is a table &#8216;user&#8217; with score. Simple enough.</p>
<table border="1">
<tbody>
<tr>
<th>id</th>
<th>username</th>
<th>score</th>
</tr>
<tr>
<td>10</td>
<td>neobie</td>
<td>530000</td>
</tr>
</tbody>
</table>
<h2>INSERT STATEMENT</h2>
<p>In my application I need to add another user with username &#8216;neobie_2&#8242; and score of 1000 less than user &#8216;neobie&#8217;.</p>
<p>I would use</p>
<blockquote><p>INSERT INTO user (username, score) VALUES (&#8216;neobie_2&#8242;, (SELECT score-1000 FROM user WHERE username = &#8216;neobie&#8217;));</p></blockquote>
<p>MySQL will return an error message <em>&#8220;You can&#8217;t specify target table &#8216;user&#8217; for update in FROM clause</em>.&#8221;. It seems like I cannot use table user twice. Let&#8217;s give an alias and change the statement to:</p>
<blockquote><p>INSERT INTO user (username, score) VALUES (&#8216;neobie_2&#8242;, (SELECT score-1000 FROM user WHERE username = &#8216;neobie&#8217;) AS x);</p></blockquote>
<p>And this would succeed my INSERT query.</p>
<h2>UPDATE STATEMENT</h2>
<p>Another circumstance, I need to add more points to the score of the user as a reward for his contribution.</p>
<p>I know I have to use ALIAS in order to update base on the existing value.</p>
<blockquote><p>UPDATE user SET score = (SELECT score+10000 from10 AS x) WHERE id = 10;</p></blockquote>
<p>This does not work either? It simply return <em>syntax error</em>.</p>
<p>Let&#8217;s try to nested the query once more.</p>
<blockquote><p>UPDATE user SET score =<br />
(SELECT score + 10000 FROM<br />
(SELECT score FROM user WHERE id = 10)<br />
as x)<br />
WHERE id = 10;</p></blockquote>
<p>The query above is equivalent to</p>
<blockquote><p>UPDATE user SET score = score + 10000 WHERE id = 10;</p></blockquote>
<p>However, if you going to <strong>update the record base on the different record value in the same table</strong>, the nested query would be come in handy. For example, updating the record with id 10, using the value from id 9.</p>
<p>Take note that always use open and close bracket for any nested query.</p>
<p>If you have better method or suggestion, feel free to share with us.</p>
<div class='wp_likes' id='wp_likes_post-108'><a class='like' href="javascript:wp_likes.like(108);" title='' ><img src="http://digitalmemo.neobie.net/wp-content/plugins/wp-likes/images/like.png" alt='' border='0'/>Like</a><span class='text'></span>
<div class='unlike'><a href="javascript:wp_likes.unlike(108);">Unlike</a></div>
</div>
<div id="crp_related"><h3>Posts which might interest you:</h3><ul><li><a href="http://digitalmemo.neobie.net/2009/03/04/mysql-default-sql-mode/" rel="bookmark" class="crp_title">MySQL Default SQL-Mode</a></li><li><a href="http://digitalmemo.neobie.net/2009/11/12/wordpress-plugin-ap-error-during-installation/" rel="bookmark" class="crp_title">WordPress Plugin API error during installation</a></li><li><a href="http://digitalmemo.neobie.net/2009/03/13/php-variable-performance/" rel="bookmark" class="crp_title">PHP variable performance</a></li><li><a href="http://digitalmemo.neobie.net/2009/08/21/countdown-counter/" rel="bookmark" class="crp_title">Countdown Counter</a></li><li><a href="http://digitalmemo.neobie.net/2009/07/16/sims-3-10615-to-127-update/" rel="bookmark" class="crp_title">Sims 3 1.0.615 to 1.2.7 Update</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div><img src="http://digitalmemo.neobie.net/wp-content/plugins/pixelstats/trackingpixel.php?post_id=108&amp;ts=1280435666" style="display:none;" alt="pixelstats trackingpixel"/>]]></content:encoded>
			<wfw:commentRss>http://digitalmemo.neobie.net/2009/03/19/insertupdate-using-existing-tablerow-value/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Default SQL-Mode</title>
		<link>http://digitalmemo.neobie.net/2009/03/04/mysql-default-sql-mode/</link>
		<comments>http://digitalmemo.neobie.net/2009/03/04/mysql-default-sql-mode/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 11:06:47 +0000</pubDate>
		<dc:creator>neobie</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[my.cnf]]></category>
		<category><![CDATA[my.ini]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[sql-mode]]></category>
		<category><![CDATA[sql_mode]]></category>
		<category><![CDATA[strict mode]]></category>
		<category><![CDATA[xampp]]></category>

		<guid isPermaLink="false">http://digitalmemo.neobie.net/?p=78</guid>
		<description><![CDATA[If developers&#8217; testing server platform configuration is different with the real server testing configuration, it could be troublesome for both developers and users, only to realize that the real system is buggy and certain process could not be completed. In worst case, undesired wrong data is inserted, resulting in unwanted aftermath. Here we talk about [...]]]></description>
			<content:encoded><![CDATA[<p>If developers&#8217; testing server platform configuration is different with the real server testing configuration, it could be troublesome for both developers and users, only to realize that the real system is buggy and certain process could not be completed. In worst case, undesired wrong data is inserted, resulting in unwanted aftermath.</p>
<h3>Here we talk about MySQL problems.</h3>
<p>By using <strong>XAMPP </strong>because of the ease of installation, the default configuration of the its MySQL without <strong>STRICT MODE </strong>is quite dangerous. For example, a wrong date format of 2009-Feb-01 instead of 2009-2-01 inserted into DATE column resulting in the value of 0000-00-00, converted by &#8220;loose&#8221; mode of mysql. The real date to be captured is definitely unrecoverable if strict mode is not enabled. By having strict mode, mysql rejects the query with an error message &#8220;invalid value for column date&#8221; or something similar. Without strict mode, a lot of problems could arise if the programming code is not perfect enough.</p>
<p>To check MySQL SQL Mode, use the query</p>
<blockquote><p>SELECT @@global.sql_mode;</p></blockquote>
<p>Running query on xampp MySQL simply return nothing. For the official version of MySQL, you should be able to read this line:</p>
<blockquote><p>STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION</p></blockquote>
<h2><span style="color: #3366ff;"><br />
How do I configure MySQL to be in STRICT mode?<br />
</span></h2>
<p>For xampp user, there is no <strong>my.ini</strong> as possessed by official MySQL. Look for <strong>my.cnf</strong> instead, as located in &lt;xampp-directory&gt;/mysql/bin/my.cnf</p>
<p>Open my.cnf using any text editor. Put the following line anywhere under [mysqld] section or else it won&#8217;t work.</p>
<blockquote><p># Set the SQL mode to strict<br />
sql-mode = &#8220;STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION&#8221;</p></blockquote>
<p>Save my.cnf, exit and remember to restart MySQL service.</p>
<div class='wp_likes' id='wp_likes_post-78'><a class='like' href="javascript:wp_likes.like(78);" title='' ><img src="http://digitalmemo.neobie.net/wp-content/plugins/wp-likes/images/like.png" alt='' border='0'/>Like</a><span class='text'></span>
<div class='unlike'><a href="javascript:wp_likes.unlike(78);">Unlike</a></div>
</div>
<div id="crp_related"><h3>Posts which might interest you:</h3><ul><li><a href="http://digitalmemo.neobie.net/2010/01/10/import-large-database-in-remote-server/" rel="bookmark" class="crp_title">Import large database in remote server</a></li><li><a href="http://digitalmemo.neobie.net/2009/03/19/insertupdate-using-existing-tablerow-value/" rel="bookmark" class="crp_title">INSERT/UPDATE using existing table/row Value</a></li><li><a href="http://digitalmemo.neobie.net/2009/08/26/working-solution-for-apache-sub-domains-configuration/" rel="bookmark" class="crp_title">Working solution for Apache Sub-domains configuration</a></li><li><a href="http://digitalmemo.neobie.net/2009/11/12/wordpress-plugin-ap-error-during-installation/" rel="bookmark" class="crp_title">WordPress Plugin API error during installation</a></li><li><a href="http://digitalmemo.neobie.net/2010/05/03/spirit-jailbreak-c0000005-error-code/" rel="bookmark" class="crp_title">Spirit jailbreak c0000005 error code</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div><img src="http://digitalmemo.neobie.net/wp-content/plugins/pixelstats/trackingpixel.php?post_id=78&amp;ts=1280435666" style="display:none;" alt="pixelstats trackingpixel"/>]]></content:encoded>
			<wfw:commentRss>http://digitalmemo.neobie.net/2009/03/04/mysql-default-sql-mode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
