Menü schliessen
Created: January 9th 2012
Last updated: May 1st 2020
Categories: Typo3
Author: Marcus Fleuti

Setup Typo3 >= 4.6 for UTF-8 charset usage / Enable UTF-8 on MySQL 5.x databases that are based on another charset (like latin1)

Tags:  MySQL,  Typo3,  UTF-8
Donation Section: Background
Monero Badge: QR-Code
Monero Badge: Logo Icon Donate with Monero Badge: Logo Text
82uymVXLkvVbB4c4JpTd1tYm1yj1cKPKR2wqmw3XF8YXKTmY7JrTriP4pVwp2EJYBnCFdXhLq4zfFA6ic7VAWCFX5wfQbCC

The goal:

It's recommended to run Typo3 >= 4.6 using a UTF-8 charset. This can be an issue if you have older Typo3 installations that are still based on latin1 using the Typo3 compatibility switch "$TYPO3_CONF_VARS['BE']['forceCharset'] = 'utf-8';" in localconf.php.

Howto:

Backup the current MySQL database using PHPMyAdmin

Login to PHPMyAdmin and execute this SQL snipped (this will change the charset of your database to UTF-8):

ALTER DATABASE MyDb CHARACTER SET utf8; //change the value 'MyDb' according to the name of your DB

Click on "Export", Select "add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT" and click on the OK on the bottom right (if you're using a large database select a compression first) and save the backed up database as a .sql (or .zip/.gz ...) file

Logon to the Typo3 backend and...

Click on "Template" -> Open up the site template setup configuration and check that the locale as well as the content type is set to UTF-8 standards:

config.locale_all = de_DE.utf-8
page.config.metaCharset = utf-8
page.config.additionalHeaders = Content-Type:text/html;charset=utf-8

Click on "Installation" -> "All configuration" -> Navigate to the textarea of [setDBinit] and enter the following there:

SET NAMES utf8;
SET SESSION character_set_server = utf8;
SET character_set_connection = utf8;
SET CHARACTER SET utf8;

Enable the following properties the "All configuration" page:

[SYS][UTF8filesystem]  -->  check!
[BE][forceCharset] = utf-8   (enter the chars 'utf-8' in the textfield. All in lower-case)

Convert the whole database into UTF-8

  1. Create a copy of your database backup file and - if needed - decompress it
  2. Open up the .sql file with your favorite editor
  3. Change all entries from
    CHARSET=latin1
    to
    CHARSET=utf8
  4. Save the file
  5. Logon to PHPMyAdmin
  6. Delete all database tables
  7. Re-Import the just edited file
  8. After the import has succeeded click on the "structure" tab again to verify that all tables and the database itself are set to UTF-8. This should look like this:
  1. Make sure that the collation settings are set to utf8_general_ci as well:

Don't forget...

  1. You will need to open your html template and save it in UTF-8

If you have problems with the conversion...

It might occur that this simple conversion steps will not succeed because converting directly from latin1 (or possibly from another charset) to utf8 is tricky. In that case you would need to convert the database to BLOB first and then convert it back to utf8 in a second step. This is far more complex. I might consider writing another tutorial about that when needed.