From: Jon Stephens Date: February 5 2006 12:33am Subject: Re: character set for Turkish characters List-Archive: http://lists.mysql.com/win32/18012 Message-Id: <43E547C3.4060501@mysql.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit > Date: Fri, 3 Feb 2006 10:58:13 +0200 > To: win32@stripped > From: "Murat Beyhan" > Subject: character set for Turkish characters > Message-Id: <20060203084945.M1299@stripped> > > Hello , > > I'm new user in mysql on Windows OS. > Actually I have problem that I don't know how can I add Turkish character > set to mysql. On official web site of mysql.com is explaining but to apply > and understand the process is little difficult for me. > Default character set was set latin and collation was swedish. > Process for add new character to Mysql is complicated could you help me how > can solve this problem... > Please help me. > Version is mysql-4.1.1a-alpha. > Thanks... > Murat Hi Murat, First of all (and please forgive me for shouting but this is very important!): PLEASE UPGRADE NOW. MySQL 4.1.1a is over two years old (released December 2003) and was alpha software (that's why the version shows "4.1.1a-alpha"). "Alpha" means "not ready for production, released only to help us find bugs" and we do not provide support for it any longer. The latest release in the 4.1 series is 4.1.16, which *is* a production release. Please visit our site at http://dev.mysql.com/downloads, download it, and install it. (Or upgrade to the latest MySQL 5.0, which is 5.0.18.) No-one should be using 4.1.1a any more! Okay, now that this been said... Specifying characters sets and collations in MySQL is not as difficult as it might appear at first glance. MySQL already supports the Latin5 (ISO 8859-9) Turkish character set. MySQL supports two collations for this character set: latin5_bin and latin5_turkish_ci - latin5_turkish_ci is the default. These are built in to MySQL and you do not need to add them. To make a table use this character set, simply add CHARSET=latin5 to your CREATE TABLE statements, like this: CREATE TABLE t1 ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) ) CHARSET=latin5; This table automatically uses the latin5_turkish_ci collation. If you'd rather use the latin5_bin collation, then you'd use this: CREATE TABLE t1 ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) ) CHARSET=latin5 COLLATE=latin5_bin; To cause all new tables in a database to use this character set, create the database like so: CREATE DATABASE mydb CHARSET=latin5; or CREATE DATABASE mydb CHARSET=latin5 COLLATE=latin5_bin; You can also use ALTER TABLE and ALTER DATABASE to change the character sets/collations for existing tables and databases. (IIRC, if you change the character set of an existing database, you must also change the character sets of any tables already in that database, if you want them to use the new character set.) You can also specify a character set/collation for an individual table column. To force the MySQL server to use Latin5 as its default character set, you'll need to reinstall the MySQL service. You can do this manually, or using the MySQL Administrator. If you prefer Unicode, MySQL supports Turkish collations for UTF-* and UCS-2. You might find these two queries helpful in making sure that all of these character sets and collations are available on your MySQL installation: mysql> SHOW COLLATION LIKE '%turk%'; +-------------------+---------+-----+---------+----------+---------+ | Collation | Charset | Id | Default | Compiled | Sortlen | +-------------------+---------+-----+---------+----------+---------+ | latin5_turkish_ci | latin5 | 30 | Yes | | 0 | | utf8_turkish_ci | utf8 | 201 | | Yes | 8 | | ucs2_turkish_ci | ucs2 | 137 | | Yes | 8 | +-------------------+---------+-----+---------+----------+---------+ 3 rows in set (0.00 sec) mysql> SHOW COLLATION LIKE '%latin5%'; +-------------------+---------+----+---------+----------+---------+ | Collation | Charset | Id | Default | Compiled | Sortlen | +-------------------+---------+----+---------+----------+---------+ | latin5_turkish_ci | latin5 | 30 | Yes | | 0 | | latin5_bin | latin5 | 78 | | | 0 | +-------------------+---------+----+---------+----------+---------+ 2 rows in set (0.00 sec) To create a table that uses the Turkish collation for UTF-8 Unicode, you'd use something like this: CREATE TABLE t1 ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) ) CHARSET=utf8 COLLATE=utf8_turkish_ci; For more details, see http://dev.mysql.com/doc/refman/4.1/en/charset-syntax.html and the sections within the one I've linked to. It's all explained there. Character sets and collations work basically the same way in MySQL 5.0 - 5.0 just has more of them. -> Don't forget to upgrade. Please don't use 4.1.1a - it is ancient!! <- cheers jon. -- Jon Stephens - jon@stripped Technical Writer - MySQL Documentation Team Brisbane, Australia (GMT +10.00) Office: +61 (7) 3388 2228 Mobile: +61 402 635 784 MySQL AB: www.mysql.com