Search code examples
mysqlcharacter-encodingdrupal-7collation

Should I alter my non utf-8 database (mysql) (default?) to utf-8 on a running Drupal 7 site?


I've got running Drupal 7 site on MySQL. Just recognised that I have the Database Encoding (and collation) other than UTF-8 while Drupal 7 docs say it needs UTF-8 (with utf8_general_ci collation). At the same time all my tables are the necessary utf-8 and utf8_general_ci. (I guess drupal setup did it this way).

My questions are:

  1. should I leave the whole system as it is or should I just alter my database to required encoding or is it necessary to convert anything after I altered the database to utf-8?
  2. Would leaving the whole system as it is cause me any trouble in the future?
  3. Is this setting for the database just a default and it doesn't matter at all for me as all my tables are set to the proper utf-8?

Thanks


Solution

  • You may or may not already be in trouble.

    When you connect, do you establish the connection as being utf8? (SET NAMES utf8, or whatever Drupal does to achieve that.)

    Is the data in your client encoded utf8? (For English, this does not matter.)

    The CHARACTER SET of every column that currently exists is already set in stone. Even if some columns are latin1 and some are utf8, the client will see them as whatever SET NAMES has established. The inconsistency does not 'hurt'. At least not until you try to store Arabic in a latin1 column.

    I would not blindly try to change anything without understanding how to correctly change it. Some attempts could make things worse.