LoginSignup
3
3

More than 5 years have passed since last update.

MySQL5.6のインストール

Last updated at Posted at 2014-12-09

前書き

サーバにMySQLをインストールすることになったので、メモ的に残しておこうかと。

内容はほとんど参考リンクのままだけど、微妙にバージョンとか違います。

インストール

rpmダウンロード

普通にyumでインストールしようとすると5.1系なのでwgetしてくる

$ mkdir ~/mysql
$ cd ~/mysql
$ wget http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-client-5.6.22-1.el6.x86_64.rpm \
http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-shared-compat-5.6.22-1.el6.x86_64.rpm \
http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-server-5.6.22-1.el6.x86_64.rpm \
http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-devel-5.6.22-1.el6.x86_64.rpm \
http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-shared-5.6.22-1.el6.x86_64.rpm

インストール

パッケージ依存関係の都合で2回に分けてyum install

$ sudo yum install MySQL-{client,devel,server,shared-compat}-5.6.22-1.el6.x86_64.rpm
$ sudo yum install MySQL-shared-5.6.22-1.el6.x86_64.rpm

yumログ

ログでインストール履歴が見れる

$ sudo tail /var/log/yum.log
(略)
Dec 09 18:31:24 Installed: MySQL-devel-5.6.22-1.el6.x86_64
Dec 09 18:31:46 Installed: MySQL-server-5.6.22-1.el6.x86_64
Dec 09 18:31:47 Installed: MySQL-shared-compat-5.6.22-1.el6.x86_64
Dec 09 18:31:52 Installed: MySQL-client-5.6.22-1.el6.x86_64
Dec 09 18:31:52 Erased: mysql-libs
Dec 09 18:32:56 Installed: MySQL-shared-5.6.22-1.el6.x86_64

初期セットアップ

MySQL起動

$ sudo service mysql start
Starting MySQL.. SUCCESS!

初期パスワード確認

$ sudo cat /root/.mysql_secret
# The random password set for the root user at Tue Dec  9 18:31:41 2014 (local time): aBcDeFgHiJkLmNoP

初回ログイン

先程確認したパスワードを使ってログイン

$ mysql -u root -p

パスワードを変えるまで何もできない

mysql> show databases;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

パスワード変更

mysql> SET PASSWORD FOR root@localhost=PASSWORD('hogefuga');
Query OK, 0 rows affected (0.01 sec)

この時点でも一応使える状態

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.02 sec)

mysql_secure_installation

一度MySQLからは出て、mysql_secure_installationコマンドを打つ。

$ mysql_secure_installation

いくつかY/nを聞かれるけど、最初(rootパスワードの変更)だけn、あとは基本Yでオッケー。

後から思ったけど、ログインしてrootパスワード変更しなくてもこっちで変更すれば良かったのでは・・・

また次の機会に確認しよう。

参考

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3