<?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>Guillaume Piot &#124; Application Developer &#38; User Interface Designer &#187; MySQL</title>
	<atom:link href="http://gpiot.com/category/development-tips/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://gpiot.com</link>
	<description></description>
	<lastBuildDate>Tue, 30 Apr 2013 08:42:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Fixing a MySQL &#8220;incorrect string value&#8221; error when save unicode string</title>
		<link>http://gpiot.com/fixing-a-mysql-incorrect-string-value-error-when-save-unicode-string/</link>
		<comments>http://gpiot.com/fixing-a-mysql-incorrect-string-value-error-when-save-unicode-string/#comments</comments>
		<pubDate>Wed, 30 May 2012 16:49:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://gpiot.com/?p=475</guid>
		<description><![CDATA[I have recently been working with a CSV list of player names, which I needed to import into MySQL. Using the CSV library in Python, I managed to read and slice my csv accordingly, here is an example: 12345678910import csv [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently been working with a CSV list of player names, which I needed to import into MySQL.</p>
<p>Using the CSV library in Python, I managed to read and slice my csv accordingly, here is an example:</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">csv</span><br />
players = <span style="color: #dc143c;">csv</span>.<span style="color: black;">reader</span><span style="color: black;">&#40;</span><span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'media/players.csv'</span>, <span style="color: #483d8b;">'rb'</span><span style="color: black;">&#41;</span>, delimiter=<span style="color: #483d8b;">','</span>, quotechar=<span style="color: #483d8b;">'|'</span><span style="color: black;">&#41;</span><br />
i = <span style="color: #ff4500;">0</span><span style="color: #66cc66;">;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> row <span style="color: #ff7700;font-weight:bold;">in</span> players:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> row<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> i <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; player = Player.<span style="color: black;">objects</span>.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: #008000;">id</span>=i<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; player.<span style="color: black;">first_name</span> = row<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; player.<span style="color: black;">save</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; i = i+<span style="color: #ff4500;">1</span></div></td></tr></tbody></table></div>
<p>In the following example, I have already created the list of players, but some Polish characters in their name appear as &#8220;?&#8221;.</p>
<p><strong>The problem is that the column in that database table (the one for the name) hasn&#8217;t got the right encoding charset, which should be UTF-8.</strong></p>
<p>The best way to convert the column to UTF-8 is to run the following command in your mysql prompt, against the right database:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ALTER TABLE players_player MODIFY COLUMN first_name VARCHAR(255)  CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;</div></td></tr></tbody></table></div>
<p>Once you&#8217;ve done this, re-run your Python import/update script and the name should be saved with the right characters.</p>
]]></content:encoded>
			<wfw:commentRss>http://gpiot.com/fixing-a-mysql-incorrect-string-value-error-when-save-unicode-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Watch slow queries on MySQL</title>
		<link>http://gpiot.com/watch-slow-queries-on-mysql/</link>
		<comments>http://gpiot.com/watch-slow-queries-on-mysql/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 18:00:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://piot.co.uk/?p=194</guid>
		<description><![CDATA[First login as root on the command line to MySQL: mysql -u root -p mysql Enter your mysql root password. Set the log slow queries variables: SET GLOBAL slow_query_log = 'ON'; Verify your variables are set properly: SHOW VARIABLES; You [...]]]></description>
			<content:encoded><![CDATA[<p>First login as root on the command line to MySQL:</p>
<pre>mysql -u root -p mysql</pre>
<p>Enter your mysql root password.</p>
<p>Set the log slow queries variables:</p>
<pre>SET GLOBAL slow_query_log = 'ON';</pre>
<p>Verify your variables are set properly:</p>
<pre>SHOW VARIABLES;
</pre>
<p>You should have something like this:</p>
<pre>slow_query_log       | ON</pre>
<pre>slow_query_log_file  | /var/lib/mysql/gp1-slow.log
</pre>
<p>Now you can check the log file to identify your slow heinous queries!</p>
]]></content:encoded>
			<wfw:commentRss>http://gpiot.com/watch-slow-queries-on-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reset root password for MySQL on Ubuntu</title>
		<link>http://gpiot.com/reset-root-password-for-mysql-on-ubuntu/</link>
		<comments>http://gpiot.com/reset-root-password-for-mysql-on-ubuntu/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 17:50:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://piot.co.uk/?p=191</guid>
		<description><![CDATA[Stop the MySQL Server. sudo /etc/init.d/mysql stop Start the mysqld configuration. sudo mysqld --skip-grant-tables &#38; Login to MySQL as root. mysql -u root mysql Replace YOURNEWPASSWORD with your new password! UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit; &#160;]]></description>
			<content:encoded><![CDATA[<ol>
<li>Stop the MySQL Server.
<pre>sudo /etc/init.d/mysql stop</pre>
</li>
<li>Start the mysqld configuration.
<pre>sudo mysqld --skip-grant-tables &amp;</pre>
</li>
<li>Login to MySQL as root.
<pre>mysql -u root mysql</pre>
</li>
<li>Replace YOURNEWPASSWORD with your new password!
<pre>UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit;</pre>
</li>
</ol>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://gpiot.com/reset-root-password-for-mysql-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL query cheat sheet</title>
		<link>http://gpiot.com/mysql-query-cheat-sheet/</link>
		<comments>http://gpiot.com/mysql-query-cheat-sheet/#comments</comments>
		<pubDate>Fri, 10 Sep 2010 11:24:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://localhost/devblog/?p=40</guid>
		<description><![CDATA[Remove all rows from a table TRUNCATE TABLE table_name;]]></description>
			<content:encoded><![CDATA[<p><strong>Remove all rows from a table</strong></p>
<p>TRUNCATE TABLE table_name;</p>
]]></content:encoded>
			<wfw:commentRss>http://gpiot.com/mysql-query-cheat-sheet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
