参考にさせて頂いたページ
基本的にはVirtualBox+VagrantでphpMyAdminを動かすまで - Qiitaを参考に進めてみる。
参考としてVagrantにCentOS6.5 + Apache2.2.15 + MySQL5.6.17 + PHP5.5 + phpMyAdmin4.1.13の構築方法 - Qiitaも合わせて読んでみる。
swap領域についてはメモリとSwap領域の確認: BlueEyesBlue
MySQLのインストールに必要なファイルをダウンロードして準備する
まず.rpmのファイルをダウンロードする。
以下の3つをダウンロードしてみた。
- MySQL-shared-compat-5.6.21-1.linux_glibc2.5.x86_64.rpm
- MySQL-client-5.6.21-1.linux_glibc2.5.x86_64.rpm
- MySQL-server-5.6.21-1.linux_glibc2.5.x86_64.rpm
これらはゲストに同期しているディレクトリに置いておく。
僕が置いているのは、今のところデフォルト設定のままなので、Vagrantfileが置いてあるディレクトリ。
vagrant ssh
su
vagrant(パスワード)
pwd
すると/home/vagrant
ディレクトリにいることがわかる。
/vagrant
ディレクトリに移動したいので
cd ../../vagrant/
で移動する。
ls
すると、
MySQL-client-5.6.21-1.linux_glibc2.5.x86_64.rpm MySQL-shared-compat-5.6.21-1.linux_glibc2.5.x86_64.rpm index.html
MySQL-server-5.6.21-1.linux_glibc2.5.x86_64.rpm Vagrantfile
みたいな感じでホストマシンから同期されたファイルがあるのがわかる。
MySQLのインストールとMySQLのstart
yum localinstall MySQL-shared-compat-5.6.21-1.linux_glibc2.5.x86_64.rpm
yum localinstall MySQL-client-5.6.21-1.linux_glibc2.5.x86_64.rpm
yum localinstall MySQL-server-5.6.21-1.linux_glibc2.5.x86_64.rpm
それぞれインストールしたときに
完了しました!
と出た。
service mysql start
と入力したら
Starting MySQL.. SUCCESS!
と表示された。
参考ページと違い、エラーは出なかった。
スワップ領域とやらが確保できているということなのかな?
メモリとSwap領域の確認: BlueEyesBlueを参考に
/sbin/swapon -s
を実行すると
Filename Type Size Used Priority
/dev/dm-1 partition 2621436 55440 -1
みたいな感じで表示された。
free
を入力すると
total used free shared buffers cached
Mem: 469396 463092 6304 348 1248 9648
-/+ buffers/cache: 452196 17200
Swap: 2621436 57292 2564144
のように表示された。
ここまででMySQLのstartとswap領域の確認ができた。
MySQLのパスワード確認とパスワード変更
cat /root/.mysql_secret
を入力すると
# The random password set for the root user at Mon Dec 29 11:22:29 2014 (local time): xxxxxxxxxx
と表示された。
xxxxxxxxxx
の部分が初期のパスワードとのこと。
MySQLにログインするので
mysql -u root -p
を入力するとパスワード入力を求められるので、さっきのxxxxxxxxxxを入力すると
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.21
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
と表示された。
ここで参考ページのように
mysql> SET PASSWORD FOR root@localhost=PASSWORD('password');
を入力すると
Query OK, 0 rows affected (0.01 sec)
と表示された。
exit;
でMySQLログアウト。
これでパスワード変更が完了した。
次回からは
mysql -u root -p
のあとで
password
を入力することでMySQLにログインできる。
参考サイトではphpMyAdminのインストールと、ちょっと使ってみるところまでやっているけど、一旦ここまでにして、phpMyAdminについては次回。