<?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>charset | Jörg Drzycimski</title>
	<atom:link href="https://drzycimski.com/tag/charset/feed/" rel="self" type="application/rss+xml" />
	<link>https://drzycimski.com/tag/charset/</link>
	<description></description>
	<lastBuildDate>Sun, 01 Oct 2017 16:52:53 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>Converting a MySQL database to UTF-8</title>
		<link>https://drzycimski.com/programmierung/converting-a-mysql-database-to-utf-8/</link>
					<comments>https://drzycimski.com/programmierung/converting-a-mysql-database-to-utf-8/#comments</comments>
		
		<dc:creator><![CDATA[Jörg]]></dc:creator>
		<pubDate>Thu, 20 Jan 2011 17:11:45 +0000</pubDate>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[charset]]></category>
		<category><![CDATA[convert database]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[utf-8]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<guid isPermaLink="false">http://www.drzycimski.com/?p=110</guid>

					<description><![CDATA[<p>I just spent about 2 days to convert my old MySQL database from latin1 / latin1_general_ci to UTF-8 character encoding. There are about a gazillion pitfalls, especially when you work on old PHP code mixed with ZF code, on a live site of a client. The first tip is&#8230; do NOT work on a live [&#8230;]</p>
<p>The post <a href="https://drzycimski.com/programmierung/converting-a-mysql-database-to-utf-8/">Converting a MySQL database to UTF-8</a> appeared first on <a href="https://drzycimski.com">Jörg Drzycimski</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I just spent about 2 days to convert my old MySQL database from latin1 / latin1_general_ci to UTF-8 character encoding. There are about a gazillion pitfalls, especially when you work on old PHP code mixed with ZF code, on a live site of a client. The first tip is&#8230; do NOT work on a live site 😉 Backup everything to a local version or a testserver, and then start to code! Fortunately, I had the site including the database on a local XAMPP environment.</p>
<p>For a coarse orientation, you can use the <a href="http://codex.wordpress.org/Converting_Database_Character_Sets">article on wordpress.org</a> to get an overview. There is no way to change the character encoding of an entire database with just a few keystrokes, so expect it to take a tad bit longer.</p>
<p>For me, the following steps did the trick, using <a href="http://www.phpmyadmin.net/" target="_blank" rel="noopener">phpMyAdmin</a> and <a href="http://www.notepad-plus-plus.org/" target="_blank" rel="noopener">Notepad++</a> (on Windows):</p>
<ol>
<li>Create a backup of the entire database with phpMyAdmin.</li>
<li>Change your database to UTF-8 (ALTER DATABASE mydb CHARACTER SET utf8;). This will only affect new tables, so you´re not thru yet.</li>
<li>Select the table(s) to change, and use the export function of phpMyAdmin.</li>
<li>Copy the exported data (INSERT INTO&#8230;) without the header (CREATE&#8230;) into Notepad++.</li>
<li>Change the table´s charset (ALTER TABLE mytable DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;).</li>
<li>Change all fields with latin charsets to utf8_general_ci (e.g. ALTER TABLE mytable CHANGE myfield myfield TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;). Pls note that this SQL only works for TEXT fields, refer to the <a href="http://codex.wordpress.org/Converting_Database_Character_Sets">article on wordpress.org</a> on how to convert ENUM, VARCHARS and so on, or use phpMyAdmin to do so for you. If you have a lot of columns with the same format to convert, just copy&amp;paste one SQL line, and change the column names in each. Paste those lines into phpMyAdmin´s SQL editor, that´s a lot faster than doing it for each column.</li>
<li>By now, you should have the table as well as all columns in UTF-8.</li>
<li>Switch to Notepad++, where all you INSERTs for that table are, and convert those lines to UTF-8.</li>
<li>Copy&amp;paste it into phpMyAdmin´s SQL editor.</li>
<li>Repeat steps 3 to 9 for each table, and you should have your database converted to UTF-8.</li>
</ol>
<p>Now, that took an hour or two ;), but there´s still the website to change to the new encoding.</p>
<p>First, start with your meta tag:</p>
<pre class="brush:html">&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
</pre>
<p>Next up, if applicable, change your database connection script in PHP:</p>
<pre class="brush:php">mysql_set_charset("utf8");
</pre>
<p>And / or if you use Zend Framework, edit your config file:</p>
<pre class="brush:php">database.params.charset = "utf8"
</pre>
<p>and your bootstrap:</p>
<pre class="brush:php">ini_set('default_charset', 'UTF-8');

$view-&gt;setEncoding('UTF-8');
</pre>
<p>That should do the trick, and your entire site runs on UTF-8 instead of latin.</p>
<p>The post <a href="https://drzycimski.com/programmierung/converting-a-mysql-database-to-utf-8/">Converting a MySQL database to UTF-8</a> appeared first on <a href="https://drzycimski.com">Jörg Drzycimski</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://drzycimski.com/programmierung/converting-a-mysql-database-to-utf-8/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
