LinuxはソースコードのインストールのMySQLを配置して同時に複数の文字セットをサポートします
2058 ワード
一、mysqlのマルチ文字セットサポート1、mysqldサービスを設定すると同時に複数の文字セットをサポートmysqldサービスのデフォルト文字セットをutf 8に変更し、latin 1、gbk、gb 2312、big 5、ascii文字セットを同時にサポートする.異なるデータベース、テーブルに対して異なる文字セット符号化を使用できます.
shell> ./configure --with-charset=utf8 --with-collation=utf8_bin --with-extra-charsets=big5,ascii,gb2312,gbk,utf8,latin1
#define HAVE_CHARSET_ascii 1#define HAVE_CHARSET_big5 1#define HAVE_CHARSET_gb2312 1#define HAVE_CHARSET_gbk 1#define HAVE_CHARSET_latin1 1#define HAVE_CHARSET_utf8 1
mysqld> set names gbk;ERROR 1115(42000):Unknown character set:'gbk'//後で./configureが完了するとconfig.hファイルにはgbk、gb 2312などの変数定義が自動的に開かれず、手動で追加を変更せざるを得ない.
mysql> show character set;
mysql> show collation like 'gb%';mysql> show collation like 'utf8%';
mysql> status……Server characterset: utf8Db characterset: utf8Client characterset: utf8Conn. characterset: utf8
mysql> create database testdb default character set utf8;mysql> show create database testdb;//データベース構築情報の検証
mysql> create table testdb.tb1 ( id int(10) unsigned NOT NULL AUTO_INCREMENT,name varchar(15) NOT NULL default '',PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARACTER SET gb2312;mysql> show create table testdb.tb1;//データテーブル確立情報の検証
mysql> set NAMES utf8;
Step1:./configure , :
shell> ./configure --with-charset=utf8 --with-collation=utf8_bin --with-extra-charsets=big5,ascii,gb2312,gbk,utf8,latin1
// latin1。
// ,utf8 collation :utf8_bin、utf8_general_ci、utf8_unicode_ci
//extra "--with-extra-charsets=all"。
Step2: make , config.h , utf8、gbk、gb2312 , ( ), :
#define HAVE_CHARSET_ascii 1#define HAVE_CHARSET_big5 1#define HAVE_CHARSET_gb2312 1#define HAVE_CHARSET_gbk 1#define HAVE_CHARSET_latin1 1#define HAVE_CHARSET_utf8 1
// config.h, ,"mysql>" "Error 1115" :
mysqld> set names gbk;ERROR 1115(42000):Unknown character set:'gbk'//後で./configureが完了するとconfig.hファイルにはgbk、gb 2312などの変数定義が自動的に開かれず、手動で追加を変更せざるを得ない.
2、 mysqld
1) mysql
mysql> show character set;
2)
mysql> show collation like 'gb%';mysql> show collation like 'utf8%';
3) mysql
mysql> status……Server characterset: utf8Db characterset: utf8Client characterset: utf8Conn. characterset: utf8
4) :
mysql> create database testdb default character set utf8;mysql> show create database testdb;//データベース構築情報の検証
5) :
mysql> create table testdb.tb1 ( id int(10) unsigned NOT NULL AUTO_INCREMENT,name varchar(15) NOT NULL default '',PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARACTER SET gb2312;mysql> show create table testdb.tb1;//データテーブル確立情報の検証
6) mysql>
mysql> set NAMES utf8;