Go Back   Cloud Computing > Support > MySQL Issues.
 

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 05-13-11, 04:38
BOD Member
 
Join Date: Dec 2010
Posts: 170
Default Change MySQL Database Collation

How can I change my MySQL database collation?
Reply With Quote
  #2 (permalink)  
Old 05-13-11, 04:50
BOD Member
 
Join Date: Jun 2009
Posts: 68
Default

Hello,

Changing MySQL database collation is easy in cpanel servers, you need to access phpMyAdmin.

Then need to select the database you wish to alter.
In phpmyadmin you will find a Operations tab in top of phpMyAdmin.
At the bottom of the page you will see the collation option.
You can now select a collation from the drop down menu and click on the Go button.

After changing the collation of a database only the new tables will be created with the new collation. The old tables in database remain on old collation.

Note : Please make a backup of database before alter the database collation.
Reply With Quote
  #3 (permalink)  
Old 05-13-11, 04:56
BOD Member
 
Join Date: Nov 2010
Posts: 202
Default

How to optimize a MySQL database using phpMyAdmin?
Reply With Quote
  #4 (permalink)  
Old 05-13-11, 05:02
BOD Member
 
Join Date: Jun 2009
Posts: 68
Default

Hello,

phpMyAdmin itself provides inbuilt function to optimize the database.
To optimize a database through phpMyAdmin.
Login to you phpMyAdmin and select the database.
Simply click [Check All] to select all tables and From the [With selected:] drop-down menu choose Optimize table. This will Optimize database tables.
Reply With Quote
  #5 (permalink)  
Old 05-21-11, 06:57
BOD Member
 
Join Date: Jan 2011
Posts: 5
Default

If you have ssh access to the server you can use the following script to change the collation of the database.

Quote:
<?php
$db = mysql_connect('localhost','database_user','passwor d');
if(!$db) echo "Unable to connect to the database - incorrect details";
mysql_select_db('database_name'); $result=mysql_query('show tables');
while($tables = mysql_fetch_array($result)) {
foreach ($tables as $key => $value) {
mysql_query("ALTER TABLE $value COLLATE utf8_general_ci");
}}
echo "The collation of your database has been successfully changed!";
?>
The above script will change the collation to 'utf8_general_ci'.

Also if you have ssh access to the server , you can optimize and repair the database using the following commands respectively.

Quote:
mysqlcheck -o database_name
mysqlcheck -r database_name

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump


All times are GMT -6. The time now is 00:49.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Copyright © 1999-2012, BODHost Ltd. All rights reserved.