データベースを使う。

WebサーバでPHPとMySQLを使うため、データベースサーバの設定を行う。

Fedora Core 6ではPHPとMySQLを連動させるために、php-mysqlというパッケージが必要になる。
また、MySQLにパスワードを設定する場合は、mod_auth_mysqlというパッケージが必要になる。
今回は、データベースが動く状態にするだけとして、ApacheやPHPとの連携については後述することにする。

私と同じようにインストール作業を行っている環境では、mysqlのパッケージはすでに導入済みのはずだが、そうではない場合はパッケージが導入されているかを調査する。

$ yum list mysql
Loading "installonlyn" plugin
Setting up repositories
core                      100% |=========================| 1.1 kB    00:00
updates                   100% |=========================| 1.2 kB    00:00
extras                    100% |=========================| 1.1 kB    00:00
Reading repository metadata in from local files
Installed Packages
mysql.i386                               5.0.27-1.fc6           installed

<

p>上のように表示された場合はインストールされている。

インストールされていない場合は、yumを利用してインストールする。

# yum install mysql

次にmysqld(データベースサーバのデーモン)が起動していないことを確認する。

$ ps -ef | grep mysql
username     16256 16229  0 16:04 pts/1    00:00:00 grep mysql

デーモンが動作していないことが確認できたら、データベースサーバを起動する。

初回起動時は、データベースの初期化が行われる。

# service mysqld start
MySQL データベースを初期化中:  Installing all prepared tables
Fill help tables

To start mysqld at boot time you have to copy support-files/mysql.server
to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h www.cecily.jp password 'new-password'
See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
                                                           [  OK  ]
MySQL を起動中:                                            [  OK  ]

データベースへログインするためのパスワードを設定する。

下の例ではrootユーザのパスワードに「new-password」と設定している。

# /usr/bin/mysqladmin -u root password 'new-password'

システム起動時にMySQLのデーモンが自動的に起動する設定を行う。

# chkconfig mysqld on

設定が反映されたことを確認する。

# chkconfig --list mysqld
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off

データベースにログインできることを確認する。

# mysql -p
Enter password: ←パスワードを入力(なにも表示されない)
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 3 to server version: 5.0.27

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

mysql>

関連記事

  1. NO IMAGE

    2010.08.20

    1Password購入。
  2. NO IMAGE

    2007.10.28

    Optiplex 755。
  3. NO IMAGE

    2009.10.06

    sshで。
  4. NO IMAGE

    2008.02.13

    メモリ購入。
  5. NO IMAGE

    2007.11.01

    結局。

コメントをお待ちしております

CALENDAR

2024年4月
 123456
78910111213
14151617181920
21222324252627
282930  

ARCHIVES

CATEGORIES