Autor Zpráva
Martin Kovac
Profil
Caute,
som zaciatocnik v MySQL a mam problemy s kodovanim.
Databazu som vytvoril nasledovne:

CREATE DATABASE 'dbname' CHARACTER SET utf8 COLLATE utf8_general_ci;

Nasledne som tabulku vytvoril pomocou datazu:

CREATE TABLE IF NOT EXISTS 'tblname' ( ... ) CHARACTER SET utf8 COLLATE utf8_general_ci;

Po prikaze status som dostal ako odpoved:
Connection id: 442
Current database: dbname
Current user: user@localhost
SSL: Not in use
Current pager: /usr/bin/less
Using outfile: ''
Using delimiter: ;
Server version: 5.0.70-log Gentoo Linux mysql-5.0.70-r1
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /var/run/mysqld/mysqld.sock
Uptime: 66 days 2 hours 32 min 7 sec

A po tomto dotaze: SHOW VARIABLES LIKE 'char%'; som dostal odpoved:
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

Konecne po dotaze: SHOW TABLE STATUS;
+-------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+-------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+
| users | MyISAM | 10 | Dynamic | 4 | 22 | 88 | 281474976710655 | 2048 | 0 | 5 | 2009-03-19 12:11:41 | 2009-03-19 12:11:41 | NULL | utf8_general_ci | NULL | | |
+-------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+

Takze som si myslel ze je vsetko v poriadku a ze mozem vlozit data do databazy takze som vykonal dotazy:
INSERT INTO tblname (fullName) VALUES ('myFullName');
INSERT INTO tblname (fullName) VALUES ('mySecondFullNamewithľščťžýáíé...');

Po dotaze: SELECT * FROM tblname som dostal vsak vysledok:
+----+----------------------+
| id | fullName |
+----+----------------------+
| 1 | myFullName |
| 2 | mySecondFullNamewith |
+----+----------------------+
2 rows in set (0.00 sec)

Takze moje data neboli spravne zapisane do databazy. Problem je ze znaky ako ľ š č ť ž ý á í é ú atd. nie su vlozene.

Kde je problem?

Ked som zobrazoval udaje z MySQL databazy pomocou PHP tiez som ziskal ten isty vysledok bez znakom uvedenych hore.
Verzia servera je: 5.0.70-log Gentoo Linux mysql-5.0.70-r1

Mozno pomoze ze som pracoval s databazou cez PuTTY release 0.57 a na WINDOWS XP PROFESSIONAL, version 2002, Service Pack 3, ENG

Dakujem kazdemu, kto mi pomoze tento problem vyriesit.
Kajman_
Profil *
Nepřekročil jste maximální velikost fullName? Pak se to ořízne, ať už tam je diakritika nebo ne.
Martin Kovac
Profil
Datovy typ a dlzka pola fullName je VARCHAR(255) - nie neprekrocil som.
Kajman_
Profil *
Tak si ještě v putty zkontrolujte translation v nastavení, zda máte utf8.
Martin Kovac
Profil
Vdaka tam bola chyba.
Toto téma je uzamčeno. Odpověď nelze zaslat.