How to upgrade MySQL 5.1 to 5.7

### Update :exclamation: 

 - How to update yum repository  **mysql57-community-dmr** --> **mysql57-community**

 With mysql57-community-dmr installed, Conflict error occurs like

```
yum install http://dev.mysql.com/get/mysql57-community-release-el6-11.noarch.rpm

Setting up Install Process
mysql57-community-release-el6-11.noarch.rpm                                                                  |  25 kB     00:00     
Examining /var/tmp/yum-root-dWCjk3/mysql57-community-release-el6-11.noarch.rpm: mysql57-community-release-el6-11.noarch
Marking /var/tmp/yum-root-dWCjk3/mysql57-community-release-el6-11.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql57-community-release.noarch 0:el6-11 will be installed
--> Processing Conflict: mysql57-community-release-el6-11.noarch conflicts mysql-community-release
No package matched to upgrade: mysql57-community-release
--> Finished Dependency Resolution
Error: mysql57-community-release conflicts with mysql-community-release-el6-7.noarch
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
```


 - Fix


```sh
yum-config-manager --disable mysql57-community-dmr

yum remove mysql-community-release-el6-7.noarch
yum install http://dev.mysql.com/get/mysql57-community-release-el6-11.noarch.rpm

yum-config-manager --enable mysql57-community
```

---

## Background
 - Conoha **Ruby on Rails** template uses MySQL 5.1 as of March 2016
 - needs to be upgraded to the latest version MySQL 5.7 quickly !

## Plan
 - from 5.1 to 5.7 : *no direct in-place upgrade path available*, so step wise... 
1. 5.1 -> 5.5 Upgrading MySQL http://dev.mysql.com/doc/refman/5.5/en/upgrading.html
1. 5.5 -> 5.6 Upgrading MySQL http://dev.mysql.com/doc/refman/5.6/en/upgrading.html
1. 5.6 -> 5.7 Upgrading MySQL http://dev.mysql.com/doc/refman/5.7/en/upgrading.html


## Preliminary
  <dt>【シンプル】CentOS6にMySQL5.7をyumで簡単にインストールする手順</dt>
  <dd>http://blog.ybbo.net/2015/03/11/how-to-install-mysql5-7-to-centos6-using-yum/</dd>

## Steps - How to upgrade
### Environment
- CentOS 6.7 installed (Red Hat Enterprise Linux Server 6.7)

```sh:/etc/issue
CentOS release 6.7 (Final)
```

### **yum repository for CentOS 6.x**
```
yum install http://dev.mysql.com/get/mysql-community-release-el6-11.noarch.rpm
```

### **shutdown MySQL 5.1 for upgrade**
```
mysql -u root -ppassword --execute="set global innodb_fast_shutdown=0"
mysqladmin -u root -ppassword shutdown
```

### **upgrade to MySQL 5.5**
```
yum-config-manager --disable mysql56-community
yum-config-manager --enable mysql55-community
yum update mysql mysql-devel mysql-server mysql-utilities
```

### **mysqld_safe && mysql_upgrade - 5.5**
```
mysqld_safe
mysql_upgrade -u root -ppassword
service mysqld stop
```

### **upgrade to MySQL 5.6**
```
yum-config-manager --disable mysql55-community
yum-config-manager --enable mysql56-community
yum update mysql mysql-devel mysql-server mysql-utilities
```

### **mysqld_safe && mysql_upgrade - 5.6**
```
mysqld_safe
mysql_upgrade -u root -ppassword
service mysqld stop
```

### **upgrade to MySQL 5.7 :heavy_exclamation_mark:**
```
yum-config-manager --disable mysql56-community
yum-config-manager --enable mysql57-community
yum update mysql mysql-devel mysql-server mysql-utilities
```

### **mysqld_safe && mysql_upgrade - 5.7**
```
mysqld_safe
mysql_upgrade -u root -ppassword
service mysqld stop
```

## Fin

```
mysql --version
mysql  Ver 14.14 Distrib 5.7.12, for Linux (x86_64)
```

Done :smiley: :tada: