MisterSimpson
Simpsons Fan
- 20 April 2006
- 2.947
- 106
Hallo wie bekomme ich am schnellsten und einfachsten eine MySQL Datenbank von Latin1 zu UTF8?
Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
<?php
$dbname = 'database';
mysql_connect('localhost', 'username', 'password');
mysql_query("ALTER DATABASE `$dbname` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
$res = mysql_query("SHOW TABLES FROM `$dbname`");
while($row = mysql_fetch_row($res)) {
$query = "ALTER TABLE {$dbname}.`{$row[0]}` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci";
mysql_query($query);
$query = "ALTER TABLE {$dbname}.`{$row[0]}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci";
mysql_query($query);
}
echo 'Alle Tabellen konvertiert.';
?>