haiju's 開発メモ

開発に必要な情報を自分用にメモ

CentOS6.5のデフォルトインストールのMySQLをアンインストールして5.6.xをインストール

以前、VMのCentOS7.xの古いMariaDBをアンインストールして、

最新を入れ直すという作業をやったと思うが、今回はCentOS6.5

でデフォルトインストール済みのMySQL 5.1.73が邪魔なので

アンインストールしてインストール可能な5.6.xの最新版をインス

トールするための作業手順をメモ(ΦωΦ)

[作業手順]

1.デフォルトでインストール済みのMySQLをアンインストール。

※一応、古いMySQLがインストールされてないか確認するコマンド

 は以下。

# rpm -qa | grep mysql
php-mysqlnd-5.5.9-1.el6.remi.x86_64
mysql-libs-5.1.73-3.el6_5.x86_64
mysql-5.1.73-3.el6_5.x86_64
mysql-connector-odbc-5.1.5r1144-7.el6.x86_64

# mysql --version
mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1

※もし古いバージョンがデフォルトでインストール済みの場合は、

 全削除。

# yum remove mysql*

2-1. MySQL公式から自分のOSバージョンに合うyumリポジトリ

 探しに行く。でも、「mysql80」って書いてあって最新過ぎる

 気がするので、却下w

2-2.参考サイトの上2つのように、5.6.xのリポジトリを指定してMySQL

 をインストール。

# yum install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm

# yum install mysql-client mysql-server

3. インストール実行後、バージョンを確認。

# rpm -qa | grep mysql
mysql-community-libs-5.6.40-2.el6.x86_64
mysql-community-release-el6-5.noarch
mysql-community-server-5.6.40-2.el6.x86_64
mysql-community-common-5.6.40-2.el6.x86_64
php-mysqlnd-5.5.9-1.el6.remi.x86_64
mysql-community-client-5.6.40-2.el6.x86_64

# mysql --version
mysql Ver 14.14 Distrib 5.6.40, for Linux (x86_64) using EditLine wrapper

4. mysqlにログイン。

 4-1.起動コマンドを実行。

# /etc/init.d/mysqld start

 4-2.rootでログイン実行。

# mysql -uroot -p
Enter password:    --- まだ、ここは未入力でエンター実行
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.40 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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>

 4-3.rootのパスワードを設定。

mysql> set password = password('New Passwd')

※'New Passwd' --- 任意のパスワードを入力 

Query OK, 0 rows affected (0.01 sec)

5. 一旦、mysqlからログアウトし、mysql_secure_installationを実行。

mysql> exit
Bye

# /usr/bin/mysql_secure_installation

※参考サイト(1番上)の通りの回答で実行すればOK。

6. 自動起動設定の確認。

# chkconfig mysqld on

# chkconfig | grep mysql
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off

※上記結果の通りならOK。

[参考サイト]

runble1.com

qiita.com

qiita.com