<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
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/"
> <channel><title>Comments on: Convert MySQL database from one encoding/collation into another</title> <atom:link href="https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html/feed" rel="self" type="application/rss+xml" /><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html</link> <description>Tiny bits of bioinformatics, [web-]programming etc</description> <lastBuildDate>Mon, 01 Jan 2024 17:12:20 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>https://wordpress.org/?v=3.8.27</generator> <item><title>By: SY</title><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-724244</link> <dc:creator><![CDATA[SY]]></dc:creator> <pubDate>Thu, 09 May 2019 18:40:34 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-724244</guid> <description><![CDATA[Updated for mysqli:
&lt;code&gt;
query(&quot; SHOW TABLES &quot;) or die($mysqli-&gt;error);
while ($row_tables = $rs_tables-&gt;fetch_row()) {
$table = $mysqli-&gt;real_escape_string($row_tables[0]);
// Alter table collation
// ALTER TABLE `account` DEFAULT CHARACTER SET utf8
if ($show_alter_table)
echo(&quot;ALTER TABLE `$table` DEFAULT CHARACTER SET $character_set;\n&quot;);
$rs = $mysqli-&gt;query(&quot; SHOW FULL FIELDS FROM `$table` &quot;) or die($mysqli-&gt;error);
while ($row = $rs-&gt;fetch_assoc()) {
if ($row[&#039;Collation&#039;] == &#039;&#039; &#124;&#124; $row[&#039;Collation&#039;] == $convert_to)
continue;
// Is the field allowed to be null?
if ($row[&#039;Null&#039;] == &#039;YES&#039;)
$nullable = &#039; NULL &#039;;
else
$nullable = &#039; NOT NULL &#039;;
// Does the field default to null, a string, or nothing?
if ($row[&#039;Default&#039;] === null &amp;&amp; $row[&#039;Null&#039;] == &#039;YES&#039;)
$default = &quot; DEFAULT NULL &quot;;
elseif ($row[&#039;Default&#039;] != &#039;&#039;)
$default = &quot; DEFAULT &#039;&quot; . $mysqli-&gt;real_escape_string($row[&#039;Default&#039;]) . &quot;&#039;&quot;;
else
$default = &#039;&#039;;
// sanity check and fix:
if ($nullable == &#039; NOT NULL &#039; &amp;&amp; $default == &#039; DEFAULT NULL &#039;) {
$default = &#039;&#039;;
echo &quot;/* Warning: wrong combination of &#039;default value&#039; and &#039;NULL-flag&#039; detected - and fixed! */\n&quot;;
echo &quot;/* Diagnostics: row[Null] = &#039;$row[Null]&#039;, row[Default] = &quot; . $mysqli-&gt;real_escape_string($row[&#039;Default&#039;]) . &quot;, MySQL version: &quot; . $mysqli-&gt;get_server_info() . &quot; */\n&quot;;
}
// Don&#039;t alter INT columns: no collations, and altering them drops autoincrement values
if (strpos($row[&#039;Type&#039;], &#039;int&#039;) !== false) {
$show_alter_field = false;
} else {
$show_alter_field = true;
}
// Alter field collation:
// ALTER TABLE `tab` CHANGE `field` `field` CHAR( 5 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL
if ($show_alter_field) {
$field = $mysqli-&gt;real_escape_string($row[&#039;Field&#039;]);
echo &quot;ALTER TABLE `$table` CHANGE `$field` `$field` $row[Type] CHARACTER SET $character_set COLLATE $convert_to $nullable $default;\n&quot;;
}
}
}
&lt;/code&gt;]]></description> <content:encoded><![CDATA[<p>Updated for mysqli:</p><p><code><br
/> query(" SHOW TABLES ") or die($mysqli-&gt;error);</p><p>while ($row_tables = $rs_tables-&gt;fetch_row()) {<br
/> $table = $mysqli-&gt;real_escape_string($row_tables[0]);</p><p> // Alter table collation<br
/> // ALTER TABLE `account` DEFAULT CHARACTER SET utf8<br
/> if ($show_alter_table)<br
/> echo("ALTER TABLE `$table` DEFAULT CHARACTER SET $character_set;\n");</p><p> $rs = $mysqli-&gt;query(" SHOW FULL FIELDS FROM `$table` ") or die($mysqli-&gt;error);</p><p> while ($row = $rs-&gt;fetch_assoc()) {</p><p> if ($row['Collation'] == '' || $row['Collation'] == $convert_to)<br
/> continue;</p><p> // Is the field allowed to be null?<br
/> if ($row['Null'] == 'YES')<br
/> $nullable = ' NULL ';<br
/> else<br
/> $nullable = ' NOT NULL ';</p><p> // Does the field default to null, a string, or nothing?<br
/> if ($row['Default'] === null &amp;&amp; $row['Null'] == 'YES')<br
/> $default = " DEFAULT NULL ";<br
/> elseif ($row['Default'] != '')<br
/> $default = " DEFAULT '" . $mysqli-&gt;real_escape_string($row['Default']) . "'";<br
/> else<br
/> $default = '';</p><p> // sanity check and fix:<br
/> if ($nullable == ' NOT NULL ' &amp;&amp; $default == ' DEFAULT NULL ') {<br
/> $default = '';<br
/> echo "/* Warning: wrong combination of 'default value' and 'NULL-flag' detected - and fixed! */\n";<br
/> echo "/* Diagnostics: row[Null] = '$row[Null]', row[Default] = " . $mysqli-&gt;real_escape_string($row['Default']) . ", MySQL version: " . $mysqli-&gt;get_server_info() . " */\n";<br
/> }</p><p> // Don't alter INT columns: no collations, and altering them drops autoincrement values<br
/> if (strpos($row['Type'], 'int') !== false) {<br
/> $show_alter_field = false;<br
/> } else {<br
/> $show_alter_field = true;<br
/> }</p><p> // Alter field collation:<br
/> // ALTER TABLE `tab` CHANGE `field` `field` CHAR( 5 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL<br
/> if ($show_alter_field) {<br
/> $field = $mysqli-&gt;real_escape_string($row['Field']);<br
/> echo "ALTER TABLE `$table` CHANGE `$field` `$field` $row[Type] CHARACTER SET $character_set COLLATE $convert_to $nullable $default;\n";<br
/> }<br
/> }<br
/> }<br
/> </code></p> ]]></content:encoded> </item> <item><title>By: Bogdan</title><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-363754</link> <dc:creator><![CDATA[Bogdan]]></dc:creator> <pubDate>Mon, 27 Jul 2015 22:00:26 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-363754</guid> <description><![CDATA[I&#039;m glad it is useful :)
By the way, technically the latest script version is _only_ :D about 5 years old - but yeah, that&#039;s surprisingly long anyway in the modern age of permanent change ;)]]></description> <content:encoded><![CDATA[<p>I&#8217;m glad it is useful <img
src="https://bogdan.org.ua/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley" /></p><p>By the way, technically the latest script version is _only_ <img
src="https://bogdan.org.ua/wp-includes/images/smilies/icon_biggrin.gif" alt=":D" class="wp-smiley" /> about 5 years old &#8211; but yeah, that&#8217;s surprisingly long anyway in the modern age of permanent change <img
src="https://bogdan.org.ua/wp-includes/images/smilies/icon_wink.gif" alt=";)" class="wp-smiley" /></p> ]]></content:encoded> </item> <item><title>By: Michael</title><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-363742</link> <dc:creator><![CDATA[Michael]]></dc:creator> <pubDate>Mon, 27 Jul 2015 20:36:52 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-363742</guid> <description><![CDATA[Your script is still helpful more than 7 years later!!!  My shopping cart provider had a bug in their UTF 8 conversion script, which was part of the upgrade process to a newer version of their cart.  Their script had the same NOT NULL DEFAULT NULL problem that gave you such a hard time.  You&#039;ve provided a marvelous service in making this script available and modifying it based on community feedback!]]></description> <content:encoded><![CDATA[<p>Your script is still helpful more than 7 years later!!!  My shopping cart provider had a bug in their UTF 8 conversion script, which was part of the upgrade process to a newer version of their cart.  Their script had the same NOT NULL DEFAULT NULL problem that gave you such a hard time.  You&#8217;ve provided a marvelous service in making this script available and modifying it based on community feedback!</p> ]]></content:encoded> </item> <item><title>By: sorin</title><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-135503</link> <dc:creator><![CDATA[sorin]]></dc:creator> <pubDate>Wed, 06 Jul 2011 19:01:19 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-135503</guid> <description><![CDATA[Please take a look at http://stackoverflow.com/questions/6600534/easiest-way-to-repair-charset-and-collation-on-a-mysql-database because this does include an answer that really works. You current script doesnt work in all cases and even when it does it sets the charset and collation for each column and this is not a good practice, instead it should only set it at database level and reset table and column to defaults (meaning database value). Also the collation you setup is not the recommended one.]]></description> <content:encoded><![CDATA[<p>Please take a look at <a
href="http://stackoverflow.com/questions/6600534/easiest-way-to-repair-charset-and-collation-on-a-mysql-database" rel="nofollow">http://stackoverflow.com/questions/6600534/easiest-way-to-repair-charset-and-collation-on-a-mysql-database</a> because this does include an answer that really works. You current script doesnt work in all cases and even when it does it sets the charset and collation for each column and this is not a good practice, instead it should only set it at database level and reset table and column to defaults (meaning database value). Also the collation you setup is not the recommended one.</p> ]]></content:encoded> </item> <item><title>By: sofian</title><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-134943</link> <dc:creator><![CDATA[sofian]]></dc:creator> <pubDate>Sat, 07 May 2011 08:47:26 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-134943</guid> <description><![CDATA[ok thank you verry much bogdan]]></description> <content:encoded><![CDATA[<p>ok thank you verry much bogdan</p> ]]></content:encoded> </item> <item><title>By: Bogdan</title><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-134933</link> <dc:creator><![CDATA[Bogdan]]></dc:creator> <pubDate>Fri, 06 May 2011 13:10:42 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-134933</guid> <description><![CDATA[&lt;blockquote&gt;to copy-paste: first click the &quot;Plain text&quot; header&quot;&lt;/blockquote&gt;
If there is no Collation for a field, then there is nothing to change - this script will do nothing as well.]]></description> <content:encoded><![CDATA[<blockquote><p>to copy-paste: first click the &#8220;Plain text&#8221; header&#8221;</p></blockquote><p>If there is no Collation for a field, then there is nothing to change &#8211; this script will do nothing as well.</p> ]]></content:encoded> </item> <item><title>By: sofian</title><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-134932</link> <dc:creator><![CDATA[sofian]]></dc:creator> <pubDate>Fri, 06 May 2011 06:07:49 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-134932</guid> <description><![CDATA[sorry
it not work for me .
i get download the file .
and wen paste it , the numbers paste too , i clear them .
i want to ask you please :
i have afield on my database that not have colaction , and it wan&#039;t to change to utf8 (by phpmyadmin ) , is your script force it to change ?
thank you]]></description> <content:encoded><![CDATA[<p>sorry<br
/> it not work for me .<br
/> i get download the file .<br
/> and wen paste it , the numbers paste too , i clear them .</p><p>i want to ask you please :<br
/> i have afield on my database that not have colaction , and it wan&#8217;t to change to utf8 (by phpmyadmin ) , is your script force it to change ?</p><p>thank you</p> ]]></content:encoded> </item> <item><title>By: Bogdan</title><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-134923</link> <dc:creator><![CDATA[Bogdan]]></dc:creator> <pubDate>Thu, 05 May 2011 21:38:59 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-134923</guid> <description><![CDATA[@Sofian,
copy-paste the script into a PHP file on your web-hosting/server (e.g. &quot;convert.php&quot;).
Then access the script with your browser (http://your-domain-here/path-to/convert.php), follow the instruction for DB backup and code line removal.
You will get a set of SQL statements which you can then copy-paste into your DB admin tool (most commonly phpMyAdmin).
Alternatively, you can run this script from the command line (e.g. using php-cli) directly on the server.]]></description> <content:encoded><![CDATA[<p>@Sofian,</p><p>copy-paste the script into a PHP file on your web-hosting/server (e.g. &#8220;convert.php&#8221;).<br
/> Then access the script with your browser (<a
href="http://your-domain-here/path-to/convert.php" rel="nofollow">http://your-domain-here/path-to/convert.php</a>), follow the instruction for DB backup and code line removal.<br
/> You will get a set of SQL statements which you can then copy-paste into your DB admin tool (most commonly phpMyAdmin).</p><p>Alternatively, you can run this script from the command line (e.g. using php-cli) directly on the server.</p> ]]></content:encoded> </item> <item><title>By: sofian</title><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-134912</link> <dc:creator><![CDATA[sofian]]></dc:creator> <pubDate>Thu, 05 May 2011 06:39:04 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-134912</guid> <description><![CDATA[hi Bogdan
hi evrry one
please just tell me how to use the script !
copy the text to were ?
please tell me
realy i dont know how to use it
thank you]]></description> <content:encoded><![CDATA[<p>hi Bogdan<br
/> hi evrry one<br
/> please just tell me how to use the script !<br
/> copy the text to were ?<br
/> please tell me<br
/> realy i dont know how to use it</p><p>thank you</p> ]]></content:encoded> </item> <item><title>By: Bogdan</title><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-134750</link> <dc:creator><![CDATA[Bogdan]]></dc:creator> <pubDate>Wed, 13 Apr 2011 21:41:28 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-134750</guid> <description><![CDATA[Lenny23: yes. Just set $convert_to = &#039;utf8_unicode_ci&#039;.]]></description> <content:encoded><![CDATA[<p>Lenny23: yes. Just set $convert_to = &#8216;utf8_unicode_ci&#8217;.</p> ]]></content:encoded> </item> <item><title>By: Lenny23</title><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-134740</link> <dc:creator><![CDATA[Lenny23]]></dc:creator> <pubDate>Wed, 13 Apr 2011 15:46:40 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-134740</guid> <description><![CDATA[Is it possible to convert with this script from utf8_general_ci to utf8_unicode_ci?]]></description> <content:encoded><![CDATA[<p>Is it possible to convert with this script from utf8_general_ci to utf8_unicode_ci?</p> ]]></content:encoded> </item> <item><title>By: PHP script to convert mysql collation &#124; PETROS KARIPIDIS</title><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-134605</link> <dc:creator><![CDATA[PHP script to convert mysql collation &#124; PETROS KARIPIDIS]]></dc:creator> <pubDate>Sat, 19 Mar 2011 14:28:14 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-134605</guid> <description><![CDATA[[...] I also found the following scripts that might be handy: http://www.phpwact.org/php/i18n/utf-8/mysql http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html    This entry was posted in Scripts and tagged charset, collation, convert, mysql, php, script. [...]]]></description> <content:encoded><![CDATA[<p>[...] I also found the following scripts that might be handy: <a
href="http://www.phpwact.org/php/i18n/utf-8/mysql" rel="nofollow">http://www.phpwact.org/php/i18n/utf-8/mysql</a> <a
href="http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html" rel="nofollow">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html</a> This entry was posted in Scripts and tagged charset, collation, convert, mysql, php, script. [...]</p> ]]></content:encoded> </item> <item><title>By: David Madl</title><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-134554</link> <dc:creator><![CDATA[David Madl]]></dc:creator> <pubDate>Wed, 16 Feb 2011 10:57:37 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-134554</guid> <description><![CDATA[Wonderful, huge time saver - thank you!
David]]></description> <content:encoded><![CDATA[<p>Wonderful, huge time saver &#8211; thank you!</p><p>David</p> ]]></content:encoded> </item> <item><title>By: Bogdan</title><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-126732</link> <dc:creator><![CDATA[Bogdan]]></dc:creator> <pubDate>Sun, 26 Dec 2010 13:33:24 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-126732</guid> <description><![CDATA[Sherlock,
the script does not modify the database - this is a precaution.
You have to run these queries yourself.
This is to ensure that you take full responsibility for your actions, and have all the backups you need.
You may use phpmyadmin to run those queries.]]></description> <content:encoded><![CDATA[<p>Sherlock,</p><p>the script does not modify the database &#8211; this is a precaution.<br
/> You have to run these queries yourself.<br
/> This is to ensure that you take full responsibility for your actions, and have all the backups you need.</p><p>You may use phpmyadmin to run those queries.</p> ]]></content:encoded> </item> <item><title>By: sherlock</title><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-126715</link> <dc:creator><![CDATA[sherlock]]></dc:creator> <pubDate>Sun, 26 Dec 2010 11:07:56 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-126715</guid> <description><![CDATA[Indeed, a great script, STILL, it didn&#039;t work for me :(
I am using MODx CMS and needed such a script to alter my collation to utf8
The script ran pretty well and here is a short snippet I got on my screen:
&lt;code&gt;
ALTER TABLE `sitename_access_actiondom` DEFAULT CHARACTER SET utf8;
ALTER TABLE `sitename_access_actiondom` CHANGE `target` `target` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci  NOT NULL  ;
ALTER TABLE `sitename_access_actiondom` CHANGE `principal_class` `principal_class` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci  NOT NULL   DEFAULT &#039;modPrincipal&#039;;
ALTER TABLE `sitename_access_actions` DEFAULT CHARACTER SET utf8;
ALTER TABLE `sitename_access_actions` CHANGE `target` `target` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci  NOT NULL  ;
ALTER TABLE `sitename_access_actions` CHANGE `principal_class` `principal_class` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci  NOT NULL   DEFAULT &#039;modPrincipal&#039;;
.............
&lt;code&gt;
I checked my db in phpMyAdmin and still, all fields&#039; collation have &#039;latin1_swedish_ci&#039;
What am i missing here?]]></description> <content:encoded><![CDATA[<p>Indeed, a great script, STILL, it didn&#8217;t work for me <img
src="https://bogdan.org.ua/wp-includes/images/smilies/icon_sad.gif" alt=":(" class="wp-smiley" /></p><p>I am using MODx CMS and needed such a script to alter my collation to utf8</p><p>The script ran pretty well and here is a short snippet I got on my screen:<br
/> <code><br
/> ALTER TABLE `sitename_access_actiondom` DEFAULT CHARACTER SET utf8;<br
/> ALTER TABLE `sitename_access_actiondom` CHANGE `target` `target` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci  NOT NULL  ;<br
/> ALTER TABLE `sitename_access_actiondom` CHANGE `principal_class` `principal_class` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci  NOT NULL   DEFAULT 'modPrincipal';<br
/> ALTER TABLE `sitename_access_actions` DEFAULT CHARACTER SET utf8;<br
/> ALTER TABLE `sitename_access_actions` CHANGE `target` `target` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci  NOT NULL  ;<br
/> ALTER TABLE `sitename_access_actions` CHANGE `principal_class` `principal_class` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci  NOT NULL   DEFAULT 'modPrincipal';<br
/> .............<br
/> </code><code></p><p>I checked my db in phpMyAdmin and still, all fields' collation have 'latin1_swedish_ci'</p><p>What am i missing here?</code></p> ]]></content:encoded> </item> <item><title>By: Bogdan</title><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-124893</link> <dc:creator><![CDATA[Bogdan]]></dc:creator> <pubDate>Mon, 13 Dec 2010 11:58:53 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-124893</guid> <description><![CDATA[&lt;blockquote cite=&quot;Damien&quot;&gt;I was wondering if the generated SQL could be optimized, by grouping the changes for multiple columns to convert in a given table, into a single ALTER TABLE statement.&lt;/blockquote&gt;
Yes, it could be done. Looks like the only change needed is merging and comma-separating all the CHANGE statements (according to &lt;a href=&quot;http://dev.mysql.com/doc/refman/5.1/en/alter-table.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;mysql refman&lt;/a&gt;).
I&#039;ll consider implementing this performance improvement soon.]]></description> <content:encoded><![CDATA[<blockquote
cite="Damien"><p>I was wondering if the generated SQL could be optimized, by grouping the changes for multiple columns to convert in a given table, into a single ALTER TABLE statement.</p></blockquote><p>Yes, it could be done. Looks like the only change needed is merging and comma-separating all the CHANGE statements (according to <a
href="http://dev.mysql.com/doc/refman/5.1/en/alter-table.html" target="_blank" rel="nofollow">mysql refman</a>).</p><p>I&#8217;ll consider implementing this performance improvement soon.</p> ]]></content:encoded> </item> <item><title>By: Damien</title><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-124890</link> <dc:creator><![CDATA[Damien]]></dc:creator> <pubDate>Mon, 13 Dec 2010 11:33:59 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-124890</guid> <description><![CDATA[Dear Bogdan
Many thanks for your useful script, it has done a perfect job in converting my database from latin1_swedish_ci to utf8_general_ci.
I was wondering if the generated SQL could be optimized, by grouping the changes for multiple columns to convert in a given table, into a single ALTER TABLE statement.
The reason I&#039;m asking you this, is that in the DB I just converted there is a large MyISAM table containing a BLOB (1.2 GB data file) as well as 6 varchar columns. Your script generated 7 distinct ALTER TABLE statements (one for the table, plus one for each column to convert), which ran in 8&#039;20, 4&#039;15, 3&#039;52, 4&#039;22, 6&#039;33, 5&#039;10 and 5&#039;11 respectively.
Thanks again.]]></description> <content:encoded><![CDATA[<p>Dear Bogdan</p><p>Many thanks for your useful script, it has done a perfect job in converting my database from latin1_swedish_ci to utf8_general_ci.</p><p>I was wondering if the generated SQL could be optimized, by grouping the changes for multiple columns to convert in a given table, into a single ALTER TABLE statement.</p><p>The reason I&#8217;m asking you this, is that in the DB I just converted there is a large MyISAM table containing a BLOB (1.2 GB data file) as well as 6 varchar columns. Your script generated 7 distinct ALTER TABLE statements (one for the table, plus one for each column to convert), which ran in 8&#8217;20, 4&#8217;15, 3&#8217;52, 4&#8217;22, 6&#8217;33, 5&#8217;10 and 5&#8217;11 respectively.</p><p>Thanks again.</p> ]]></content:encoded> </item> <item><title>By: Kawika</title><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-108808</link> <dc:creator><![CDATA[Kawika]]></dc:creator> <pubDate>Fri, 23 Jul 2010 04:15:39 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-108808</guid> <description><![CDATA[Thanks so much!!  This was just the script I needed to fix my Drupal website that was having this problem.  Found you through the Drupal issue queues.  Now my database is much happier.]]></description> <content:encoded><![CDATA[<p>Thanks so much!!  This was just the script I needed to fix my Drupal website that was having this problem.  Found you through the Drupal issue queues.  Now my database is much happier.</p> ]]></content:encoded> </item> <item><title>By: Bogdan</title><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-107470</link> <dc:creator><![CDATA[Bogdan]]></dc:creator> <pubDate>Mon, 28 Jun 2010 12:03:03 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-107470</guid> <description><![CDATA[I&#039;ve just updated the script - try it and let me know if that works for you.
Hopefully, this is the last fix for this annoying problem.]]></description> <content:encoded><![CDATA[<p>I&#8217;ve just updated the script &#8211; try it and let me know if that works for you.</p><p>Hopefully, this is the last fix for this annoying problem.</p> ]]></content:encoded> </item> <item><title>By: antoh</title><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-107469</link> <dc:creator><![CDATA[antoh]]></dc:creator> <pubDate>Mon, 28 Jun 2010 11:13:40 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comment-107469</guid> <description><![CDATA[Error
SQL query:
ALTER TABLE `agenda_categorie` CHANGE `titre` `titre` varchar( 225 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT NULL ;
MySQL said: Documentation
#1067 - Invalid default value for &#039;titre&#039;
help plz!!!]]></description> <content:encoded><![CDATA[<p>Error</p><p>SQL query:</p><p>ALTER TABLE `agenda_categorie` CHANGE `titre` `titre` varchar( 225 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT NULL ;</p><p>MySQL said: Documentation<br
/> #1067 &#8211; Invalid default value for &#8216;titre&#8217;</p><p>help plz!!!</p> ]]></content:encoded> </item> </channel> </rss>