character set for Turkish characters
am 03.02.2006 09:58:13 von Murat Beyhan
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
______________________________________
XamimeLT - installed on mailserver for domain @deprem.gov.tr
Queries to: postmaster@deprem.gov.tr
______________________________________
The views and opinions expressed in this e-mail message are the sender's own
and do not necessarily represent the views and the opinions of Earthquake Research Dept.
of General Directorate of Disaster Affairs.
Bu e-postadaki fikir ve gorusler gonderenin sahsina ait olup, yasal olarak T.C.
B.I.B. Afet Isleri Gn.Mud. Deprem Arastirma Dairesi'ni baglayici nitelikte degildir.
--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=gcdmw-win32@m.gmane.org
Re: character set for Turkish characters
am 05.02.2006 01:33:07 von Jon Stephens
> Date: Fri, 3 Feb 2006 10:58:13 +0200
> To: win32@lists.mysql.com
> From: "Murat Beyhan"
> Subject: character set for Turkish characters
> Message-Id: <20060203084945.M1299@deprem.gov.tr>
>
> 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@mysql.com
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
--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=gcdmw-win32@m.gmane.org