Skip to content
WJunction - Webmaster Forum

Tutorials & Guides How to Change Default Table Charset Collation

Status
Not open for further replies.

-sky-

Experienced Member
799
2011
130
i need share some tutor about how to Mass convert mymsql table charset collation

example : Convert / change charset UTF-8 Collate to charset Latin 1 or ISO-8951-1 this it's will be change Mass

1. Open notepad and paste this script save with name wtf you need
ex: charset.php

PHP:
<?php
// Database info
$dbhost = 'localhost';
$dbuser = 'your DB User here';
$dbpass = 'Your DB PAss here'
$dbname = 'Your DB Name Here';
//---------------
header('Content-type: text/plain');
$dbconn = mysql_connect($dbhost, $dbuser, $dbpass) or die( mysql_error() );
$db = mysql_select_db($dbname) or die( mysql_error() );

$sql = 'SHOW TABLES';
$result = mysql_query($sql) or die( mysql_error() );
while ( $row = mysql_fetch_row($result) )
{
$table = mysql_real_escape_string($row[0]);
$sql = "ALTER TABLE $table DEFAULT CHARACTER SET latin1 COLLATE latin1_general_ci";
mysql_query($sql) or die( mysql_error() );
print "$table changed to iso-8859-1.\n";
}

mysql_close($dbconn);  
?>

see the red ...what default charset you need

thanks
 
Status
Not open for further replies.

About the author

S
Experienced Member · Joined
Internet
799
Messages
130
Reactions
246
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom