MySQL/utf8
をテンプレートにして作成
[
トップ
] [
タイトル一覧
|
ページ一覧
|
新規
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
*** utf8mb4 [#i644bfc1]
- さらに ''utf8mb4'' というのもある.
*** 作成時に文字コードを指定 [#v3d64d11]
mysql> CREATE DATABASE db_name DEFAULT CHARACTER SET utf8;
mysql> CREATE TABLE table_name (......) TYPE=MyISAM DEFA...
*** 設定ファイルで文字コードを指定 [#ge06ab12]
- /etc/my.cnf
[mysql]
default-character-set=utf8
[mysqld]
default-character-set=utf8
skip-character-set-client-handshake
[mysqld_safe]
default-character-set=utf8
skip-character-set-client-handshake
- check
mysql> show variables like "char%";
*** 一時的に文字コードを変更 [#hc3135f7]
mysql> show variables like "char%";
+--------------------------+----------------------------...
| Variable_name | Value ...
+--------------------------+----------------------------...
| character_set_client | latin1 ...
| character_set_connection | latin1 ...
| character_set_database | latin1 ...
| character_set_filesystem | binary ...
| character_set_results | latin1 ...
| character_set_server | latin1 ...
| character_set_system | utf8 ...
| character_sets_dir | /usr/local/mysql-5.0.67/sha...
+--------------------------+----------------------------...
この場合は latin1 を utf8にする
mysql> set character_set_client=utf8;
mysql> set character_set_connection=utf8;
mysql> set character_set_database=utf8;
mysql> set character_set_results=utf8;
mysql> set character_set_server=utf8;
mysql> show variables like "char%";
+--------------------------+----------------------------...
| 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/local/mysql-5.0.67/sha...
+--------------------------+----------------------------...
*** MySQL on PHP [#o6c947b0]
- 処理中の文字コードを UTF-8にする場合
mb_internal_encoding("utf-8");
mysql_set_charset('utf8');
または
mb_internal_encoding("utf-8");
mysql_query("SET NAMES utf8", $db);
- mb_internal_encoding("utf-8") は php.ini でも指定可能.
- SET NAMES utf8 でクエリの文字コードを指定可能.
終了行:
*** utf8mb4 [#i644bfc1]
- さらに ''utf8mb4'' というのもある.
*** 作成時に文字コードを指定 [#v3d64d11]
mysql> CREATE DATABASE db_name DEFAULT CHARACTER SET utf8;
mysql> CREATE TABLE table_name (......) TYPE=MyISAM DEFA...
*** 設定ファイルで文字コードを指定 [#ge06ab12]
- /etc/my.cnf
[mysql]
default-character-set=utf8
[mysqld]
default-character-set=utf8
skip-character-set-client-handshake
[mysqld_safe]
default-character-set=utf8
skip-character-set-client-handshake
- check
mysql> show variables like "char%";
*** 一時的に文字コードを変更 [#hc3135f7]
mysql> show variables like "char%";
+--------------------------+----------------------------...
| Variable_name | Value ...
+--------------------------+----------------------------...
| character_set_client | latin1 ...
| character_set_connection | latin1 ...
| character_set_database | latin1 ...
| character_set_filesystem | binary ...
| character_set_results | latin1 ...
| character_set_server | latin1 ...
| character_set_system | utf8 ...
| character_sets_dir | /usr/local/mysql-5.0.67/sha...
+--------------------------+----------------------------...
この場合は latin1 を utf8にする
mysql> set character_set_client=utf8;
mysql> set character_set_connection=utf8;
mysql> set character_set_database=utf8;
mysql> set character_set_results=utf8;
mysql> set character_set_server=utf8;
mysql> show variables like "char%";
+--------------------------+----------------------------...
| 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/local/mysql-5.0.67/sha...
+--------------------------+----------------------------...
*** MySQL on PHP [#o6c947b0]
- 処理中の文字コードを UTF-8にする場合
mb_internal_encoding("utf-8");
mysql_set_charset('utf8');
または
mb_internal_encoding("utf-8");
mysql_query("SET NAMES utf8", $db);
- mb_internal_encoding("utf-8") は php.ini でも指定可能.
- SET NAMES utf8 でクエリの文字コードを指定可能.
ページ名: