CentOS7にMYSQL5.6をインストールしてみた!
目的
- vagrant + virtual boxで作ったcentOS7.2上にmysql5.6をインストールする。
- インストールする環境は以前作ったpython3実行環境
mysqlのインストール
VMにSSH
$ vagrant ssh [vagrant@localhost ~]$
CentOS7標準搭載のmariadbを削除
$ sudo yum remove mariadb-libs $ rm -rf /var/lib/mysql/
mysql公式のリポジトリをインストール
$ sudo yum localinstall http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm ~~略~~ Complete! # yeah!
バージョン指定
デフォルトでmysql5.7がインストールされる(はず)のリポジトリをインストールしたので、5.6をインストールするように変更する。
また、今回はyum-config-managerを使わずに(というかインストールしていないため)バージョン指定をする。
$ sudo vi /etc/yum.repos.d/mysql-community.repo [mysql56-community] name=MySQL 5.6 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/ enabled=1 # 有効にする gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql57-community] name=MySQL 5.7 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/ enabled=0 # 無効にする gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
確認
$ yum repolist enabled | grep mysql mysql-connectors-community/x86_64 MySQL Connectors Community 59 mysql-tools-community/x86_64 MySQL Tools Community 65 mysql56-community/x86_64 MySQL 5.6 Community Server 453 # great!
インストール
sudo yum install mysql-community-server ~~略~~ Complete! # excellent!!!
確認
$ mysql -V mysql Ver 14.14 Distrib 5.6.41, for Linux (x86_64) using EditLine wrapper
mysql初期設定
自動起動の設定
$ sudo chkconfig mysqld on $ sudo service mysqld start Starting mysqld (via systemctl): [ OK ] # OK!!
rootにパスワード設定
$ /usr/bin/mysqladmin -u root password 'password' Warning: Using a password on the command line interface can be insecure. # パスワードが簡単すぎると警告が出るので、本番環境では注意。
確認
$ mysql -uroot ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) $ mysql -uroot -ppassword Warning: Using a password on the command line interface can be insecure. # 開発環境なので気にしない。 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 5.6.41 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_secure_installationも設定すべきだが、開発環境なので設定しない。