[TYPO3] cscript onvert database to utf8

R. van Twisk typo3 at rvt.dds.nl
Mon Nov 27 17:09:31 CET 2006


Alexander Heidl wrote:
> Here is my little php shell script to set the tables of an existing 
> database from whatever to utf-8:
>
> #!/path/to/php
> <?php
> mysql_connect('DB_HOST', 'DB_USERNAME', 'DB_PASSWORD')
>     or die('Could not connect: ' . mysql_error());
> echo 'Connected successfully\n';
> mysql_select_db('DB_NAME') or die('Could not select database');
>
> $sql = mysql_query('show tables');
> while($tables = mysql_fetch_row($sql)) {
>    echo "Table: {$tables[0]}\n";
>    $query = "ALTER TABLE ".$tables[0]." DEFAULT CHARACTER SET utf8 
> COLLATE utf8_general_ci";
>    $result = mysql_query($query) or die('Query failed: ' . mysql_error());
>    echo $query . " = " . $result . "\n";
> }
> ?>
>
> I couldn't be bothered doing it all by hand and I got tired of searching 
> for an solution. This did the trick for me. However. some field 
> collations still remain as they were. I am not sure if that should 
> bother me, but so far no strange behavior cold be recognized.
>
> So, please feel free to use the script if are interested. Though bear in 
> mind to backup your DB before!!! And also the usual bladibla about 
> adapting the script to your needs before it will work ;)
>
> cherio,
>
> Alex
> www.dental-offer.com
>
> _______________________________________________
>   


It was mentioned in typo3-devel already,

be carefull of you DB contains PHP serialized strings  fields.
They might not get unserialized correctly anymore after the change
to UTF-8

Ries

-- 
Ries van Twisk
Freelance Typo3 Developer
=== Private:
email: ries at vantwisk.nl
web:   http://www.rvantwisk.nl/freelance-typo3.html
skype: callto://r.vantwisk





More information about the TYPO3-english mailing list