6

How can I change my MySQL collation in WAMPSERVER from latin1_swedish_ci to UTF-8 because I think my HTML special characters are getting all messed up

stacks
  • 117
  • 1
  • 1
  • 6

2 Answers2

14

put in your C:\wamp\bin\mysql\mysql5.5.24\my.ini:

character-set-server=utf8    
collation-server=utf8_general_ci
matyig
  • 454
  • 5
  • 15
3

You could use

set names 'utf8'

each time you open a connection.

Or add the following line to your my.ini file and restart your server.

default-character-set=utf8

If you've already got tables set up you'll need to alter them too you can alter them with:

ALTER TABLE tablename COLLATE utf8_general_ci

etc or pop into phpmyadmin and do it there. Remember if you alter database collation it'll only affect new tables created after that not pre-existing ones in that database already, so you will need to alter them also.

  • Note that --default-character-set is a flag passed at time of database creation, and will apply to all tables created in the current database. In my case default-character-set does not work in my.ini. The settings in matyig's answer will apply server-wide. http://dev.mysql.com/doc/refman/5.0/en/charset-applications.html – billrichards Aug 21 '14 at 14:17