А самый первый код (
INI) вы для
UNIX-ов привели?
Конфиг в текущий момент такой:
[client]
port=3306
[mysql]
#default-character-set=cp1251
default-character-set=utf8
[mysqld]
#skip-character-set-client-handshake
port=3306
basedir="C:/MySQL55/"
datadir="C:/Documents and Settings/All Users/Application Data/MySQL/MySQL Server 5.5/Data/"
#character-set-server=cp1251
character-set-server=utf8
character-set-client-handshake
character-set-filesystem = latin1
default-storage-engine=INNODB
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
max_connections=100
query_cache_size=0
table_cache=256
tmp_table_size=18M
thread_cache_size=8
myisam_max_sort_file_size=100G
myisam_sort_buffer_size=35M
key_buffer_size=25M
read_buffer_size=64K
read_rnd_buffer_size=256K
sort_buffer_size=256K
#skip-innodb
innodb_additional_mem_pool_size=2M
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=1M
innodb_buffer_pool_size=47M
innodb_log_file_size=24M
innodb_thread_concurrency=8
Если написать
SQL.Clear;
SQL.Add('SET NAMES CP1251');
ExecSQL;
то выйдетerror:
"SET NAMES not allowed by driver"На
stackoverflow написано:
SET NAMES has been deactivated in the MySQL ODBC driver. If you are confident you can read the characters via direct access to the database (via mysql or one of MySQL's GUI front ends), then you could try to replicate what SET NAMES does. The following is from the MySQL manual:
A SET NAMES 'x' statement is equivalent to these three statements:
SET character_set_client = x;
SET character_set_results = x;
SET character_set_connection = x;
Попробовал так, но русских букв все равно нет:
procedure TForm1.LoadComboUTF8();
begin
try
with ADOQuery1 do
begin
SQL.Clear;
//SQL.Add('SET NAMES CP1251');
SQL.Add('SET character_set_client = utf8');
ExecSQL;
SQL.Clear;
SQL.Add('SET character_set_results = utf8');
ExecSQL;
SQL.Clear;
SQL.Add('SET character_set_connection = utf8');
ExecSQL;
SQL.Clear;
SQL.Add('SELECT * FROM category WHERE category = 1');
Active := True;
//ShowMessage(IntToStr(RecordCount));
end;
except
on e:Exception do
end;
AdoQuery1.First;
while not AdoQuery1.Eof do
begin
s := AdoQuery1.FieldByName('item').AsString;
i := AdoQuery1.FieldByName('category').AsInteger;
cbComboUTF8.AddItem(s, TObject(i));
AdoQuery1.Next;
end;
ADOQuery1.Close;
cbComboUTF8.ItemIndex := 0;
end;
ConnectionString такова:
Provider=MSDASQL.1;Password="";Persist Security Info=True;User ID=root;Data Source=nodeutf8;Mode=ReadWrite;Extended Properties="DSN=nodeutf8;UID=root;PWD=;";Initial Catalog=nodeutf8;Таблицу создавал так:
CREATE TABLE category
(
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
category TINYINT UNSIGNED NOT NULL,
item VARCHAR(100) CHARACTER SET UTF8 NOT NULL
);
INSERT INTO category (category, item) VALUES
(1, 'До 12'),
(1, 'После 12');
RuNTiME, у них же есть последний пункт:
"Otherwise, the database character set and collation are used. "