Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

MySQL charset problem.


Go to End


5 Posts   4804 Views

Avatar
dab

Community Member, 50 Posts

15 April 2009 at 5:45am

Edited: 16/04/2009 9:35am

I move site to new host and get problems with mysql encoding. Their support say that i should use SET NAMES and SET CHARACTER SET in my scripts, which connect to database. What should i do? How i may make default mysql encoding to unicode?

I'm set utf8 as database encoding in phpMyAdmin, install SilverStripe, but can't use russian language cause mysql save data in wrong encoding. When i copy data from phpMyAdmin->my database->table SiteTree_Live->Content field, and try to recognize which encoding used there with one charset site, i get that it is cp1251. I think that this is their default mysql encoding, and they say that i should change way how scripts connect to database.

May be i write a bit confused message, sorry.
I should resolve this issue.

Avatar
Hiker

Community Member, 2 Posts

27 August 2009 at 2:40am

I have the same problem with hoster. Only some symbols (ш, щ) crash the output. Does anybody knows how to solve it?

Avatar
Fred Condo

Community Member, 29 Posts

2 September 2009 at 10:18am

The problem is that many MySQL instances use latin1 as the default client connection character set. I am not sure if this is a best practice, but my solution for this problem is to add this at the bottom of _config.php:

# Force database connection to use UTF8.
DB::connect($databaseConfig);
DB::query('set charset utf8');
DB::query('set names utf8');

Avatar
Hiker

Community Member, 2 Posts

3 September 2009 at 9:01pm

I have found solution for the problem in this post
http://silverstripe.org/migrating-a-site-to-silverstripe/show/256159?start=8#post262150

I've put this file in my site's code directory, changed connection type to "UTF8MySQLDatabase", and run /dev/build/.

Avatar
Fred Condo

Community Member, 29 Posts

4 September 2009 at 2:08am

@Hiker, thanks. That is much nicer, because it does not prematurely open the connection to the database.