2009/08/13
■[MySQL][Ubuntu]文字コードをUTF-8に変更する。
■既存DBの変更
$>mysql -u root -p Password: mysql> set names utf8;
■設定
[mysqld]
default-character-set=utf8 ←追加 character_set_server=utf8 ←追加
[mysql]
default-character-set=utf8 ←追加
■再起動
$> sudo /etc/init.d/mysql restart
■確認
mysql> show variables like 'character%'; mysql> show variables like 'character%'; +--------------------------+----------------------------+ | 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/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec)
既存のデータベース、テーブルを変更する場合は、ALTER 〜で変更する。
↓↓↓
mysql>alter database [データベース名] default character set utf8 mysql>use [データベース名] mysql>alter table [テーブル名] charset=utf8
例)既存のテーブルの設定変更
mysql>show create table auth_group \G *************************** 1. row *************************** Table: auth_group Create Table: CREATE TABLE `auth_group` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(80) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 1 row in set (0.00 sec) mysql>alter table auth_group default charset=utf8; Query OK, 0 rows affected (0.00 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql>show create table auth_group \G *************************** 1. row *************************** Table: auth_group Create Table: CREATE TABLE `auth_group` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(80) CHARACTER SET latin1 NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 1 row in set (0.00 sec)
参考になったら、ポチッとお願いします。m(_ _)m
↓↓↓
トラックバック - http://d.hatena.ne.jp/kariostro/20090813/1250174317
リンク元
- 3 http://66.249.89.132/translate_c?hl=pt-BR&sl=ja&u=http://search.minakoe.jp/rsss/rsss.asp?qry=domain:hatena&multi=1&prev=/search?q=%E3%83%AB%E3%83%9E%E3%83%8B%E3%82%A2%E3%81%AE%E4%BA%BA%E3%81%AE%E3%
- 2 http://www.google.co.jp/search?q=mysql+データベースの文字コードを変更する&lr=lang_ja&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:ja-JP-mac:of
- 1 http://blogsearch.google.co.jp/blogsearch?hl=ja&client=news&um=1&ie=UTF-8&q=xfce&btnG=ブログ検索&lr=lang_ja
- 1 http://d.hatena.ne.jp/keyword/リモートデスクトップ
- 1 http://search.goo.ne.jp/web.jsp?PT=Firefox20&SGT=0&from=query&MT=gpg+import+git+tag&web.x=0&web.y=0&DC=10
- 1 http://search.minakoe.jp/rsss/rsss.asp?qry=domain:hatena&multi=1
- 1 http://www.google.co.jp/search?hl=ja&client=firefox-a&rls=com.ubuntu:ja:unofficial&q=android+donut+repo+sync+local_manifest+asus&btnG=検索&lr=
- 1 http://www.google.co.jp/search?hl=ja&client=firefox-a&rls=org.mozilla:ja:official&hs=wKZ&q=be+38+文字コード&btnG=検索&lr=lang_ja
- 1 http://www.google.co.jp/search?hl=ja&q=firefox3.5+ubuntu9.04&btnG=検索&lr=
- 1 http://www.google.co.jp/search?hl=ja&rlz=1G1GGLQ_JAJP301&q=ubuntu+ウィンドウ サイズ&btnG=検索&lr=