Jump to content

Manually Change DB Charset Through PHP


Recommended Posts

Posted

If you would like to be able to change the charset of your database tables to something else here is the code


<?php

// your connection

mysql_connect("localhost","DBUser","DBPass");

mysql_select_db("Your Databse Name");

// convert code

$res = mysql_query("SHOW TABLES");

while ($row = mysql_fetch_array($res))

{

    foreach ($row as $key => $table)

    {

	    mysql_query("ALTER TABLE " . $table . " CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci");

	    echo $key . " =&gt; " . $table . " CONVERTED<br />";

    }

}

?>



Make a file called tables.php or something along the line of a php file, and put it in your root folder. Copy the code and put it in that file and then fill in your DB info. When you are done run it then delete the file after it is done [it may take some time to finish depending on how many tables you have].

Change "utf8_unicode_ci" to whatever charset you want [I used unicode because it's multilangual]

This works for all databases so not only IPB based databases.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...