Mysql －　日本語が表示されない問題を解決。

<p>ウエブプログラミングやデザインを勉強しましたが、日本語のウエブサイトを作ったことがありません。</p>
<p>触ると、いっぱい問題が発生。。。</p>
<p>Mysqlで日本語が表示されない問題。</p>
<p>使っているテスト環境：</p>
<p>■　Xampp　（Apache　OSS)</p>
<p><span style="color: #000000; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'ＭＳ Ｐゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">■　</span>Mysql だけを使います。<span style="color: #000000; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'ＭＳ Ｐゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">（5.5.27）</span></p>
<p>※　Mysql の設定ファイルに関わらず、日本語が表示されます。</p>
<p>日本語が表示されるのに、「データベース」または「テーブル」のCHARACTER SET(キャラクターセット）は sjis または　utf8　です。</p>
<p>１．最初から始まりデータベースを作る場合は：</p>
<p>手順：</p>
<p>データベースを作るとき、必ず「character set &lt;<span style="color: #000000; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'ＭＳ Ｐゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">キャラクターセット名</span>&gt;」　を追加。</p>
<pre class="programlisting" style="margin: 0px; padding: 2px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; color: #000000; font-family: 'Courier New', Courier, fixed, monospace; display: block; max-width: 720px; line-height: 20px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: #eeeeee;">CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] <em class="replaceable" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; font-style: italic; font-weight: bold; background: transparent;"><code style="margin: 0px; padding: 1px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; color: inherit; font-weight: bold; font-family: 'Courier New', Courier, fixed, monospace; background-image: initial; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">db_name</code></em>
    [<em class="replaceable" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; font-style: italic; font-weight: bold; background: transparent;"><code style="margin: 0px; padding: 1px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; color: inherit; font-weight: bold; font-family: 'Courier New', Courier, fixed, monospace; background-image: initial; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">create_specification</code></em>] ...

<em class="replaceable" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; font-style: italic; font-weight: bold; background: transparent;"><code style="margin: 0px; padding: 1px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; color: inherit; font-weight: bold; font-family: 'Courier New', Courier, fixed, monospace; background-image: initial; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">create_specification</code></em>:
    [DEFAULT] CHARACTER SET [=] <em class="replaceable" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; font-style: italic; font-weight: bold; background: transparent;"><code style="margin: 0px; padding: 1px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; color: inherit; font-weight: bold; font-family: 'Courier New', Courier, fixed, monospace; background-image: initial; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">charset_name</code></em>
  | [DEFAULT] COLLATE [=] <em class="replaceable" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; font-style: italic; font-weight: bold; background: transparent;"><code style="margin: 0px; padding: 1px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; color: inherit; font-weight: bold; font-family: 'Courier New', Courier, fixed, monospace; background-image: initial; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">collation_name<br /></code></em></pre>
<p>例：</p>
<p>CREATE DATABASE user CHARACTER SET <span style="color: #0000ff;">sjis</span>; </p>
<p>CREATE DATABASE user CHARACTER SET <span style="color: #0000ff;">utf8</span>;</p>
<p>■「CHARACTER SET NAME」はテーブルに作成されておきます。</p>
<p>見たいなら：</p>
<pre class="programlisting" style="margin: 0px; padding: 2px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; color: #000000; font-family: 'Courier New', Courier, fixed, monospace; display: block; max-width: 720px; line-height: 20px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: #eeeeee;"><code style="margin: 0px; padding: 1px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; color: inherit; font-weight: bold; font-family: 'Courier New', Courier, fixed, monospace; background-image: initial; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">show character set;</code></pre>
<p> 2.途中に直す場合：</p>
<p>挿入して起きたデータは変わりません。表示されないデーターはそのまま、表示されない、CHARACTER SET を変更しても。。。</p>
<p> ※データベースなら：</p>
<pre class="programlisting" style="margin: 0px; padding: 2px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; color: #000000; font-family: 'Courier New', Courier, fixed, monospace; display: block; max-width: 720px; line-height: 20px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: #eeeeee;">ALTER {DATABASE | SCHEMA} [<em class="replaceable" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; font-style: italic; font-weight: bold; background: transparent;"><code style="margin: 0px; padding: 1px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; color: inherit; font-weight: bold; font-family: 'Courier New', Courier, fixed, monospace; background-image: initial; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">db_name</code></em>]
    <em class="replaceable" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; font-style: italic; font-weight: bold; background: transparent;"><code style="margin: 0px; padding: 1px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; color: inherit; font-weight: bold; font-family: 'Courier New', Courier, fixed, monospace; background-image: initial; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">alter_specification</code></em> ...

<em class="replaceable" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; font-style: italic; font-weight: bold; background: transparent;"><code style="margin: 0px; padding: 1px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; color: inherit; font-weight: bold; font-family: 'Courier New', Courier, fixed, monospace; background-image: initial; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">alter_specification</code></em>:
    [DEFAULT] CHARACTER SET [=] <em class="replaceable" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; font-style: italic; font-weight: bold; background: transparent;"><code style="margin: 0px; padding: 1px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; color: inherit; font-weight: bold; font-family: 'Courier New', Courier, fixed, monospace; background-image: initial; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">charset_name</code></em>
  | [DEFAULT] COLLATE [=] <em class="replaceable" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; font-style: italic; font-weight: bold; background: transparent;"><code style="margin: 0px; padding: 1px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; color: inherit; font-weight: bold; font-family: 'Courier New', Courier, fixed, monospace; background-image: initial; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">collation_name</code></em></pre>
<p> 例：</p>
<p>ALTER DATABASE user CHARACTER SET utf8;</p>
<p>ALTER DATABASE user CHARACTER SET sjis;</p>
<p>※テーブルなら：</p>
<pre class="programlisting" style="margin: 0px; padding: 2px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; color: #000000; font-family: 'Courier New', Courier, fixed, monospace; display: block; max-width: 720px; line-height: 20px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: #eeeeee;">ALTER [ONLINE | OFFLINE] [IGNORE] TABLE <em class="replaceable" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; font-style: italic; font-weight: bold; background: transparent;"><code style="margin: 0px; padding: 1px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; color: inherit; font-weight: bold; font-family: 'Courier New', Courier, fixed, monospace; background-image: initial; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">tbl_name</code></em></pre>
<pre class="programlisting" style="margin: 0px; padding: 2px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; color: #000000; font-family: 'Courier New', Courier, fixed, monospace; display: block; max-width: 720px; line-height: 20px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: #eeeeee;">| CONVERT TO CHARACTER SET <em class="replaceable" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; font-style: italic; font-weight: bold; background: transparent;"><code style="margin: 0px; padding: 1px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; color: inherit; font-weight: bold; font-family: 'Courier New', Courier, fixed, monospace; background-image: initial; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">charset_name</code></em> [COLLATE <em class="replaceable" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; font-style: italic; font-weight: bold; background: transparent;"><code style="margin: 0px; padding: 1px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; color: inherit; font-weight: bold; font-family: 'Courier New', Courier, fixed, monospace; background-image: initial; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">collation_name</code></em>]
| [DEFAULT] CHARACTER SET [=] <em class="replaceable" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; font-style: italic; font-weight: bold; background: transparent;"><code style="margin: 0px; padding: 1px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; color: inherit; font-weight: bold; font-family: 'Courier New', Courier, fixed, monospace; background-image: initial; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">charset_name</code></em> [COLLATE [=] <em class="replaceable" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; font-style: italic; font-weight: bold; background: transparent;"><code style="margin: 0px; padding: 1px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; color: inherit; font-weight: bold; font-family: 'Courier New', Courier, fixed, monospace; background-image: initial; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">collation_name</code></em>]</pre>
<p> </p>
<p>例：</p>
<p>ALTER TABLE user CONVERT TO CHARACTER SET sjis;</p>
<p>又は：</p>
<p>ALTER TABLE user CHARACTER SET sjis;</p>
<p><span style="color: #ff0000;">※注意：</span></p>
<p><span style="color: #0000ff;">もし、プログラミングしたら、このクエリーを必ず最初に送信すれば、大丈夫。</span></p>
<pre class="programlisting" style="margin: 0px; padding: 2px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; color: #000000; font-family: 'Courier New', Courier, fixed, monospace; display: block; max-width: 720px; line-height: 20px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: #eeeeee;"><code style="margin: 0px; padding: 1px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; color: inherit; font-weight: bold; font-family: 'Courier New', Courier, fixed, monospace; background-image: initial; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">set names &lt;キャラクターセット名&gt;;</code></pre>
<p> ※便利なコマンド：</p>
<p>作成したデータベース、テーブルの<span style="color: #000000; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'ＭＳ Ｐゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">キャラクターセット</span>情報を見たいときは、このコマンドを実行しよう。</p>
<pre class="programlisting" style="margin: 0px; padding: 2px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; color: #000000; font-family: 'Courier New', Courier, fixed, monospace; display: block; max-width: 720px; line-height: 20px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: #eeeeee;"><code style="margin: 0px; padding: 1px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; color: inherit; font-weight: bold; font-family: 'Courier New', Courier, fixed, monospace; background-image: initial; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">SHOW CREATE TABLE &lt;テーブル名&gt;;<br />
SHOW CREATE DATABASE &lt;データベース名&gt;;<br /></code></pre>
<p> </p>