1

When in in a text-area I write words with acceted letters ....the application store the words in mysql with some errors E.g. if i write può in my sql I have può

How can i solve it?

jmj
  • 237,923
  • 42
  • 401
  • 438
Alex
  • 2,075
  • 5
  • 27
  • 39

1 Answers1

1

To change an existing table to use the UTF-8 charset:

ALTER TABLE tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;

To set the default charset of the database to UTF8 for tables you will create in the future:

ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_unicode_ci;

You can use either utf8_general_ci or utf8_unicode_ci. It is explained at What's the difference between utf8_general_ci and utf8_unicode_ci that there is a difference between them in the speed and accuracy of the sorting, with utf8_unicode_ci being more accurate and the performance gain of using utf8_general_ci being very minimal.

(Also, be aware, when you are doing queries in the mysql console in the command prompt, it will not display as UTF-8 even when it is stored properly. Its a limitation of the command prompt.)

Community
  • 1
  • 1
developerwjk
  • 8,619
  • 2
  • 17
  • 33
  • This was a missing piece in my puzzle--thanks. For anyone else there struggling with this portion, as well as reading/writing accented characters into/out of mySQL, be sure to include this last UTF-8 line after connecting: `$dbs = mysql_pconnect($dbsServer,$dbsUsername,$dbsPassword); mysql_select_db($dbsName, $dbs); mysql_set_charset('utf8',$dbs);` – cbmtrx Nov 15 '15 at 17:46