- b2evolution CMS User Manual
- Installation / Upgrade
- Upgrade
- Upgrading your database to UTF-8
Upgrading your database to UTF-8
Nowadays, using UTF-8 as character encoding is almost a must. If you want to know what we are talking about here, please read this: UTF-8 Encoding and if you need to go a little deeper, please try with this: Unicode.
From b2evolution version 5, we recommend the usage of UTF-8 for all users.
Automatic conversion
Starting with version 5.1
b2evolution has its own tool to convert all of your database to UTF-8. All you have to do is follow these steps:
- Go to your install home (i.e.
http://mydomain.com/install
). - Select the radio button Upgrade your DB to UTF-8.
- Click the button "GO!".
This will perform the conversion of each table in your b2evolution database one by one. (Note the tool will convert all tables in the b2evolution database).
Back-office maintenance tool
Starting with version 5.2, a maintenance tool is available in the back-office. It lets you to perform an automatic upgrade of your database encoding anytime you want.
Manual UTF-8 conversion
For sites below version 5.1, there is a manual option to perform the same conversion. In order to make this job easier, you could follow this instructions (before of that, please make a copy of your entire database):
- Create a new file named
ut8_upgrade.php
and paste this code:
<?php
require_once dirname(__FILE__).'/conf/_config.php';
require_once $inc_path.'_main.inc.php';
echo '<h2>'.T_('Upgrading all tables in b2evolution MySQL database to UTF-8...').'</h2>';
evo_flush();
$db_tables = $DB->get_col( 'SHOW TABLES FROM `'.$db_config['name'].'` LIKE "'.$tableprefix.'%"' );
foreach( $db_tables as $table )
{
echo "Converting $table...<br />\n";
evo_flush();
$DB->query( 'ALTER TABLE `'.$table.'`
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci,
CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci' );
}
echo "Changing default charset of DB...<br />\n";
evo_flush();
$DB->query( 'ALTER DATABASE `'.$db_config['name'].'` CHARACTER SET utf8 COLLATE utf8_general_ci' );
?>
<p><?php echo T_('Upgrading done!')?></p>
- Put it in
/blogs/
. - Run the script on php command line or directly at your web browser: http://yourdomain.com/blogs/ut8_upgrade.php
- Delete the file
/blogs/utf8_upgrade.php
(optional - there is no need to use it again)
This will change your database charset to UTF-8
and the collations to utf8_general_ci
.