June 2008
MonTueWedThuFriSatSun
  Aug »
 1
2345678
9101112131415
16171819202122
23242526272829
30 

Month June 2008

Fixing existing data when switching character set in MySQL

When altering a database, table or field from one character set to another, existing data will probably look garbled since it is expected to be in the new character set. To “convert” existing data is not always easy. This method (found in the comments of a blog entry I have lost the url for) works as long as you can keep the database “locked” when you do this. Otherwise you will convert any new data entered and make that data look garbled.

Altering character set and collation of tables in MySQL

Altering the character set and collation of a table is sometimes not enough. You may have to alter the actual fields in the table to get MySQL to comply in some cases. I don’t know why or when MySQL does this. ALTER TABLE my_table DEFAULT CHARSET=utf8 COLLATE=utf8_swedish_ci;   ALTER TABLE my_table MODIFY my_field varchar(255) CHARACTER [...]

Preferred character set and collation in MySQL

My preferred character set is utf8. One big drawback in many cases can be that the default collation ignores accents for characters. The result is that “halla” and “hallå” is interpreted as the same word. This is of-course bad for storing general data such as names users or products that may very well have accented [...]

Replacing characters in MySQL table data

This may be useful when for example the character encoding has been messed up and you need to correct existing data. This example will correct swedish accented characters in a uft8 – latin1 mixup. UPDATE my_table SET my_field = REPLACE(my_field,’Ã¥’,'å’);   UPDATE my_table SET my_field = REPLACE(my_field,’ä’,'ä’);   UPDATE my_table SET my_field = REPLACE(my_field,’ö’,'ö’);   [...]

Delete all .svn folders from a project

find ./ -name “.svn” -exec rm -rf {} \; found @ http://cephas.net/blog/2007/04/06/command-line-script-to-delete-svn-files-folders/