MYSQL5の設定

投稿者: | 2010年8月16日
Pocket

対象サーバについて

製品名 OpenBlockS 600
OS(kernel ver) Debian lenny(2.6.29)
CPU 600MHz(AMCC PowerPC 405EX)
メモリ 1GB(DDR2 SDRAM)
ストレージ 8GB(Compact Flash)

事前確認

www:~# updatedb
www:~# locate mysql
www:~# 

mysql関連のファイルが存在しないことを確認します。

www:~# dpkg -l | grep mysql
www:~# 

mysql関連のPKGがインストールされていないことを確認します。

www:~# ps -ef | grep mysql
root      2409  2380  0 01:13 pts/0    00:00:00 grep mysql
www:~# 

mysqlのプロセスが無いことを確認します。

www:~# aptitude show mysql-server mysql-client
パッケージ: mysql-server
状態: インストールされていません
バージョン: 5.0.51a-24+lenny5
優先度: 任意
セクション: misc
メンテナ: Debian MySQL Maintainers 
展開サイズ: 94.2k
依存: mysql-server-5.0
提供元: mysql-server-5.0
説明: MySQL database server (metapackage depending on the latest version)
 This is an empty package that depends on the current "best" version of mysql-server (currently
 mysql-server-5.0), as determined by the MySQL maintainers. Install this package if in doubt about which MySQL
 version you need. That will install the version recommended by the package maintainers.

 MySQL is a fast, stable and true multi-user, multi-threaded SQL database server. SQL (Structured Query
 Language) is the most popular database query language in the world. The main goals of MySQL are speed,
 robustness and ease of use.
ホームページ: http://dev.mysql.com/

パッケージ: mysql-client
状態: インストールされていません
バージョン: 5.0.51a-24+lenny5
優先度: 任意
セクション: misc
メンテナ: Debian MySQL Maintainers 
展開サイズ: 86.0k
依存: mysql-client-5.0
提供元: mysql-client-5.0
説明: MySQL database client (metapackage depending on the latest version)
 This is an empty package that depends on the current "best" version of mysql-client (currently
 mysql-client-5.0), as determined by the MySQL maintainers. Install this package if in doubt about which MySQL
 version you need. That will install the version recommended by the package maintainers.

 MySQL is a fast, stable and true multi-user, multi-threaded SQL database server. SQL (Structured Query
 Language) is the most popular database query language in the world. The main goals of MySQL are speed,
 robustness and ease of use.
ホームページ: http://dev.mysql.com/

導入するMySQLのバージョンを確認しておきます。

インストール

www:~# aptitude install mysql-server mysql-client
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
拡張状態情報を読み込んでいます
パッケージの状態を初期化しています... 完了
タスクの記述を読み込んでいます... 完了
以下の新規パッケージがインストールされます:
  bsd-mailx{a} exim4{a} exim4-base{a} exim4-config{a} exim4-daemon-light{a} libdbd-mysql-perl{a}
  libdbi-perl{a} libhtml-template-perl{a} libmysqlclient15off{a} libnet-daemon-perl{a} libplrpc-perl{a}
  mailx{a} mysql-client mysql-client-5.0{a} mysql-common{a} mysql-server mysql-server-5.0{a}
更新: 0 個、新規インストール: 17 個、削除: 0 個、保留: 0 個。
40.6MB のアーカイブを取得する必要があります。展開後に 118MB のディスク領域が新たに消費されます。
先に進みますか? [Y/n/?] Y

...

インストール処理が続きますので省略しますが、以下のような問合せがあるのでrootのパスワードを投入します。

パッケージの設定

--------------------------------- mysql-server-5.0 を設定しています ---------------------------------
x 強制ではないですが、MySQL を管理する "root" ユーザのパスワードを設定することを強くお勧めします。  x
x                                                                                                   x
x 入力が空の場合はパスワードは変更されません。                                                      x
x                                                                                                   x
x MySQL の "root" ユーザに対する新しいパスワード:                                                   x
x                                                                                                   x
x abcdefgh_________________________________________________________________________________________ x
x                                                                                                   x
x                                              <了解>                                               x
x                                                                                                   x
-----------------------------------------------------------------------------------------------------

パッケージの設定

------ mysql-server-5.0 を設定しています -------
x                                              x
x                                              x
x MySQL の "root" ユーザパスワードの再入力:    x
x                                              x
x abcdefgh____________________________________ x
x                                              x
x                    <了解>                    x
x                                              x
------------------------------------------------

本サイトではabcdefghに設定したと仮定します。

mysqlの特権ユーザとOSのrootユーザは異なる点に注意して下さい。

起動確認

プロセス確認

www:~# ps -ef | grep mysql
root      3439     1  0 01:27 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe
mysql     3476  3439  2 01:27 ?        00:00:03 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock
root      3477  3439  0 01:27 ?        00:00:00 logger -p daemon.err -t mysqld_safe -i -t mysqld
root      4299  2380  0 01:29 pts/0    00:00:00 grep mysql

mysqld_safeとmysqldプロセスが存在することを確認します。

rootログインの確認

www:~# mysql -uroot -pabcdefgh
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 28
Server version: 5.0.51a-24+lenny5 (Debian)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> 

ログインできました。

データディレクトリの確認

mysql> SHOW VARIABLES LIKE 'datadir';
+---------------+-----------------+
| Variable_name | Value           |
+---------------+-----------------+
| datadir       | /var/lib/mysql/ |
+---------------+-----------------+
1 row in set (0.01 sec)

mysql> system ls -al /var/lib/mysql/
合計 20540
drwxr-xr-x  4 mysql mysql     4096 2011-04-03 03:07 .
drwxr-xr-x 24 root  root      4096 2011-04-03 01:26 ..
-rw-r--r--  1 root  root         0 2011-04-03 01:26 debian-5.0.flag
-rw-rw----  1 mysql mysql  5242880 2011-04-03 03:07 ib_logfile0
-rw-rw----  1 mysql mysql  5242880 2011-04-03 01:27 ib_logfile1
-rw-rw----  1 mysql mysql 10485760 2011-04-03 03:07 ibdata1
drwxr-xr-x  2 mysql root      4096 2011-04-03 01:27 mysql
-rw-------  1 root  root         7 2011-04-03 01:27 mysql_upgrade_info

/var/lib/mysql/の下にデータベースやテーブルファイルが作成されます。

上記のib_logfile0,ib_logfile1,ibdata1はInnoDBストレージエンジン関連のファイルです。本サイトの環境ではMyISAMを使用しますので(理由については後述)、本ファイルは不要になります。そこで、MySQLの設定ファイルの[mysqld]セクションに以下の設定を追記します。

master:/var/lib# vi /etc/mysql/my.cnf
   (省略)
[mysqld]
   (省略)
skip-innodb

本サイトでは上記3ファイルは削除してしまいました。今のところ特に支障は出ていませんが、本当に削除しても不具合が出ないかは分かりません。

起動直後におけるデータベースの確認

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
+--------------------+
2 rows in set (0.01 sec)

mysqlデータベースにはmysqlにおけるユーザやデータベースの管理テーブルが存在しています。

INFORMATION_SCHEMAデータベースはメタデータへのアクセスを提供します。(ちなみにINFORMATION_SCHEMAはデータベース ディレクトリを作成しません。)

起動直後におけるユーザの確認

mysql> SELECT user, host from mysql.user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| root             | 127.0.0.1 |
| root             | www       |
| debian-sys-maint | localhost |
| root             | localhost |
+------------------+-----------+
4 rows in set (0.00 sec)

ユーザrootが127.0.0.1とホスト名とlocalhostからアクセスできるように自動設定されています。

debian-sys-maintはDebian特有のメンテナンスユーザで、MySQLの起動や停止などで使用されます。

起動直後におけるストレージエンジンの確認

mysql> SHOW ENGINES;
+------------+----------+----------------------------------------------------------------+
| Engine     | Support  | Comment                                                        |
+------------+----------+----------------------------------------------------------------+
| MyISAM     | DEFAULT | Default engine as of MySQL 3.23 with great performance         |
| MEMORY     | YES      | Hash based, stored in memory, useful for temporary tables      |
| InnoDB     | YES      | Supports transactions, row-level locking, and foreign keys     |
| BerkeleyDB | NO       | Supports transactions and page-level locking                   |
| BLACKHOLE  | YES      | /dev/null storage engine (anything you write to it disappears) |
| EXAMPLE    | NO       | Example storage engine                                         |
| ARCHIVE    | YES      | Archive storage engine                                         |
| CSV        | YES      | CSV storage engine                                             |
| ndbcluster | DISABLED | Clustered, fault-tolerant, memory-based tables                 |
| FEDERATED  | YES      | Federated MySQL storage engine                                 |
| MRG_MYISAM | YES      | Collection of identical MyISAM tables                          |
| ISAM       | NO       | Obsolete storage engine                                        |
+------------+----------+----------------------------------------------------------------+
12 rows in set (0.00 sec)

「Engine」がストレージエンジン名で、「Support」がYESのものが利用可能です。

また「Support」がDEFAULTになっているもの(本環境ではMyISAM)がデフォルトで選択されるストレージエンジンです。

この中で、よく利用されるストレージエンジンはMyISAMとInnoDBです。InnoDBは、MyISAMではサポートされないトランザクション処理(※1)、参照整合性制約をサポートしており、ロックレベルも行単位でかけられるため、更新の多いシステムで有効です。その一方で、MyISAMと比較してより多くのディスク領域を必要とするなどの欠点もあります。

本サイトは更新者が私のみでほとんど発生しないため、MyISAMのままとします。

(※1)トランザクション機能は複数の処理を1つの単位とみなし、処理結果を保証する機能です。

MyISAMテーブルを作成すると以下のような拡張子のファイルが作成されます。

データファイル MYD
インデックスファイル MYI
frm テーブル定義ファイル

新たに作成したデータベースではありませんが、mysqlデータベースを参考に例を載せておきます。

mysql> system ls -al /var/lib/mysql/mysql/
合計 788
drwxr-xr-x 2 mysql root    4096 2011-04-03 01:27 .
drwxr-xr-x 4 mysql mysql   4096 2011-04-03 20:17 ..
-rw-rw---- 1 mysql mysql      0 2011-04-03 01:27 columns_priv.MYD
-rw-rw---- 1 mysql mysql   1024 2011-04-03 01:27 columns_priv.MYI
-rw-rw---- 1 mysql mysql   8820 2011-04-03 01:27 columns_priv.frm
-rw-rw---- 1 mysql mysql   1752 2011-04-03 02:35 db.MYD
-rw-rw---- 1 mysql mysql   4096 2011-04-03 02:54 db.MYI
-rw-rw---- 1 mysql mysql   9494 2011-04-03 01:27 db.frm
      (省略)

再起動確認

www:~# /etc/init.d/mysql stop
Stopping MySQL database server: mysqld.
www:~# ps -ef | grep mysql
root      4351  2380  0 01:38 pts/0    00:00:00 grep mysql
www:~# /etc/init.d/mysql start
Starting MySQL database server: mysqld.
Checking for corrupt, not cleanly closed and upgrade needing tables..

Warningのようなものが出ています。

www:~# less /var/log/mysql.err
www:~# less /var/log/mysql.log
www:~# 
www:~# mysql -uroot -pabcdefgh
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 38
Server version: 5.0.51a-24+lenny5 (Debian)

mysql> SHOW WARNINGS;
Empty set (0.00 sec)

ログには特に出ていません。気持ち悪いですが特に害は無さそうなので気にしないことにします。

ユーザの追加

GRANT文について

MySQLでユーザを作成する際にはGRANT文を使用します。

構文は以下の通りです({}の中は|で区切られたものから一つを選択)

GRANT 権限 ON {*.テーブル名 | *.* | データベース名.* | データベース名.テーブル名}
 TO ユーザ名@接続元ホスト(ネットワーク)
 IDENTIFIED BY 'パスワード';

*は全てを意味します。

代表的な権限を以下に載せます。

ALL [PRIVILEGES] 全ての権限を付与。PRIVILEGESは省略可能
SELECT SELECT文の実行権限
USAGE 権限を持たないユーザを作成する際に使用
GRANT OPTION 作成したユーザが権限を追加できる権限

GRANT OPTIONだけは他と異なり、WITH GRANT OPTIONを別途指定します(後で例を挙げます。)

接続元ホストは以下のような指定が可能です。

TO ユーザ名@localhost →localhostからアクセス

TO ユーザ名@’%’

TO ユーザ名@

→全てのサーバからアクセス

TO ユーザ名@’サーバ名’

TO ユーザ名@’192.168.0.1′

→ホスト、IP限定でアクセス

TO ユーザ名@’192.168.1.%’

TO ユーザ名@’192.168.%’

→ネットワーク単位でアクセス

本サーバでは、メンテナンス用のdbadminとアプリケーション接続用のapluserを作成します。

メンテナンスユーザdbadminの作成

www:~# mysql -uroot -pabcdefgh
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 38
Server version: 5.0.51a-24+lenny5 (Debian)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> GRANT ALL PRIVILEGES ON *.* to dbadmin@'localhost' IDENTIFIED BY 'abcdefgh' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

→メンテナンスユーザは常にlocalhostからのアクセスを想定しているため接続元にlocalhostを指定します。

また、dbadminにてユーザを作成できるようにWITH GRANT OPTIONを指定しています。

アプリケーション接続ユーザapluserの作成

GRANT OPTIONの試験も兼ねてdbadminで作成します。

www:~# mysql -udbadmin -pabcdefgh
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 39
Server version: 5.0.51a-24+lenny5 (Debian)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> CREATE DATABASE application DEFAULT CHARSET=UTF8;
Query OK, 1 row affected (0.00 sec)

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| application        |
| mysql              |
+--------------------+
3 rows in set (0.01 sec)

apluserが接続するデータベース(application)を作成しておきます。

mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON application.* TO 'apluser'@'192.168.0.%' IDENTIFIED BY 'abcdefgh';
Query OK, 0 rows affected (0.01 sec)

mysql> 

事後確認

mysql> SELECT user, host from mysql.user;
+------------------+--------------+
| user             | host         |
+------------------+--------------+
| root             | 127.0.0.1    |
| apluser          | 192.168.0.%  |
| root             | www          |
| dbadmin          | localhost    |
| debian-sys-maint | localhost    |
| root             | localhost    |
+------------------+--------------+
6 rows in set (0.01 sec)

→dbadmin とapluserが作成されていることが確認できます。

mysql> SHOW GRANTS FOR dbadmin@localhost;
+-------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for dbadmin@localhost                                                                                                              |
+-------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'dbadmin'@'localhost' IDENTIFIED BY PASSWORD '*0947C389A6D5A485D1AAAAAAAAAAA9B058212378' WITH GRANT OPTION |
+-------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> SHOW GRANTS FOR apluser@'192.168.0.%';
+-------------------------------------------------------------------------------------------------------------------+
| Grants for apluser@192.168.0.%                                                                                   |
+-------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'apluser'@'192.168.0.%' IDENTIFIED BY PASSWORD '*0947C389A6D5AAAAAAAAAAA8DF1459B058212378' |
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `application`.* TO 'apluser'@'192.168.0.%'   |
+-------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

→設定どおり、権限が付与されていることを確認します。

パスワード変更の確認

以下の二つの方法があります。

mysql> SET PASSWORD FOR dbadmin@localhost = PASSWORD('aaaaaaaa');
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* to dbadmin@'localhost' IDENTIFIED BY 'aaaaaaaa' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

上記コマンドでパスワードがaaaaaaaaに変更されます。

権限削除

mysql> REVOKE SELECT ON application.* FROM apluser@'192.168.0.%';
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW GRANTS FOR apluser@'192.168.0.%';
+-------------------------------------------------------------------------------------------------------------------+
| Grants for apluser@192.168.0.%                                                                                   |
+-------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'apluser'@'192.168.0.%' IDENTIFIED BY PASSWORD '*0947C389A6D5A485D1AA36E8DF1459B058212378' |
| GRANT INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `application`.* TO 'apluser'@'192.168.0.%'           |
+-------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

→SELECTが消えていることが確認できます。

ユーザの削除

直接mysqlデータベースのuserテーブルを操作して、該当のレコードを削除します。

mysql> DELETE FROM mysql.user WHERE user='apluser' AND host= '192.168.0.%';
Query OK, 1 row affected (0.00 sec)

mysql> SELECT user, host from mysql.user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| root             | 127.0.0.1 |
| root             | www       |
| dbadmin          | localhost |
| debian-sys-maint | localhost |
| root             | localhost |
+------------------+-----------+
5 rows in set (0.00 sec)

→apluserが削除されたことが確認できます。

MySQLで日本語を使う

文字化けを回避するために、MySQLサーバ、DB、クライアント側で使用するキャラクタセットをあわせておくことが重要です。

まずはじめに、MySQLサーバがサポートしているキャラクタセットを調べます。

www:~# mysql -udbadmin -pabcdefgh
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 46
Server version: 5.0.51a-24+lenny5 (Debian)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
mysql>
mysql> SHOW COLLATION;
+----------------------+----------+-----+---------+----------+---------+
| Collation            | Charset  | Id  | Default | Compiled | Sortlen |
+----------------------+----------+-----+---------+----------+---------+
	(中略)
| ujis_japanese_ci     | ujis     |  12 | Yes     | Yes      |       1 |
| ujis_bin             | ujis     |  91 |         | Yes      |       1 |
| sjis_japanese_ci     | sjis     |  13 | Yes     | Yes      |       1 |
| sjis_bin             | sjis     |  88 |         | Yes      |       1 |
	(中略)
| utf8_general_ci      | utf8     |  33 | Yes     | Yes      |       1 |
| utf8_bin             | utf8     |  83 |         | Yes      |       1 |
| utf8_unicode_ci      | utf8     | 192 |         | Yes      |       8 |
	(中略)
+----------------------+----------+-----+---------+----------+---------+
126 rows in set (0.01 sec)

→「Compiled」がYesになっているものはMySQLのインストールで組み込まれ、利用可能なキャラクタセットになります。

一方、現在設定されているキャラクタセットを確認するには以下のコマンドを使用します。

mysql> SHOW VARIABLES LIKE 'character_set_%';
+--------------------------+----------------------------+
| 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/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.01 sec)

本サーバではUTF8を使用したいため、/etc/my.cnfのいくつかのセクションに「default-character-set = utf8」を設定します。

mysql> system vi /etc/mysql/my.cnf
    (省略)
[client]
    (省略)
default-character-set = utf8

[mysqld]
    (省略)
default-character-set = utf8

[mysqldump]
    (省略)
default-character-set = utf8

[mysql]
    (省略)
default-character-set = utf8

※PHPアプリからMySQLにアクセスして利用することを想定されている方は、別途、PHP5-MYSQLの設定の文字化け対策の箇所も参考にしてみて下さい。

上記を各セクションの末尾に追加して保存後、mysqlを再起動して、再度確認します。

www:~# /etc/init.d/mysql restart
Stopping MySQL database server: mysqld.
Starting MySQL database server: mysqld.
Checking for corrupt, not cleanly closed and upgrade needing tables..
www:~# mysql -udbadmin -pabcdefgh
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 28
Server version: 5.0.51a-24+lenny5 (Debian)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> SHOW VARIABLES LIKE 'character_set_%';
+--------------------------+----------------------------+
| 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)

→設定が反映されましたので、こちらのデータを題材に日本語を試してみます。

mysql> use application
Database changed
mysql> create table address (
    -> No int not null primary key auto_increment,
    -> Name varchar(40),
    -> Age int,
    -> PostCord varchar(8),
    -> Address varchar(80)
    -> );
Query OK, 0 rows affected (0.02 sec)

mysql> DESCRIBE address;
+----------+-------------+------+-----+---------+----------------+
| Field    | Type        | Null | Key | Default | Extra          |
+----------+-------------+------+-----+---------+----------------+
| No       | int(11)     | NO   | PRI | NULL    | auto_increment |
| Name     | varchar(40) | YES  |     | NULL    |                |
| Age      | int(11)     | YES  |     | NULL    |                |
| PostCord | varchar(8)  | YES  |     | NULL    |                |
| Address  | varchar(80) | YES  |     | NULL    |                |
+----------+-------------+------+-----+---------+----------------+
5 rows in set (0.01 sec)

mysql> SHOW CREATE TABLE address\G
*************************** 1. row ***************************
       Table: address
Create Table: CREATE TABLE `address` (
  `No` int(11) NOT NULL auto_increment,
  `Name` varchar(40) default NULL,
  `Age` int(11) default NULL,
  `PostCord` varchar(8) default NULL,
  `Address` varchar(80) default NULL,
  PRIMARY KEY  (`No`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
1 row in set (0.00 sec)

mysql> insert into address (Name,Age,PostCord,Address) values ('北海道太郎','70','064-0001','札幌市札幌3丁目');
Query OK, 1 row affected (0.00 sec)

mysql> insert into address (Name,Age,PostCord,Address) values ('青森次郎','65','030-0001','青森市青森2丁目');
Query OK, 1 row affected (0.00 sec)

mysql> select * from address;
+----+-----------------+------+----------+---------------------------+
| No | Name            | Age  | PostCord | Address                   |
+----+-----------------+------+----------+---------------------------+
|  1 | 北海道太郎      |   70 | 064-0001 | 札幌市札幌3丁目         |
|  2 | 青森次郎        |   65 | 030-0001 | 青森市青森2丁目         |
+----+-----------------+------+----------+---------------------------+
2 rows in set (0.00 sec)

→日本語の投入および閲覧が可能なことが確認できました。

参考文献

MySQLによるタフなサイトの作り方

よちよち歩きのLinux

紀子さん@へぼぷろぐらまの日常

Pocket

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です