2017年6月27日 星期二

CentOS 6.x upgrade PHP, MySQL

● Upgrade CentOS 6.x

  1. Change to root.
  2. Backup import data. Ex: /etc, /var/log, web, mysql ...
  3. yum update
  4. reboot

Reference: Upgrade to CentOS 6.7 from CentOS 6.6/6.5/6.4/6.3/6.2/6.1/6.0

● Upgrade PHP 5.6
  1. wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
  2. wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
  3. rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
  4. vi /etc/yum.repos.d/remi.repo。設定 [remi] 和 [remi-php56] 的 enabled=1
  5. yum update php*


● Upgrade MySQL 5.7
  1. service mysqld stop
  2. Backup MySQL databases. mkdir /var/lib/mysqlcopy; cp -aR /var/lib/mysql/* /var/lib/mysqlcopy
  3. Backup to file. mysqldump -u root -p --all-databases > all.sql
  4. vi /etc/yum.repos.d/atomic.repo, enabled = 0 (若沒有 atomic.repo 可跳過)
  5. yum install http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
  6. vi /etc/yum.repos.d/mysql-community.repo。設定 [mysql57-community] 的 enabled=1
  7. yum update mysql
  8. service mysqld start
Reference: How to upgrade MySQL 5.5 to 5.6/5.7 on Linux


● MySQL Daemon failed to start after upgrade
請查看 /var/log/mysqld.log 的啟動失敗記錄。
我遇到的是 Fatal error: mysql.user table is damaged.
這一篇說只能重建 database。

如果希望復原資料(我沒試過):

  1. 另外裝一台舊版的 mysql
  2. 把 /var/lib/mysql/* 複製過去
  3. 重新啟動 mysqld
  4. 用 mysqldump 把舊資料轉出成一個檔案 all.sql
  5. 把 all.sql 拿到 mysql 5.7 匯入。指令為 mysql -u -p < all.sql
Reference:


● 重建 database
  1. rm -fr /var/lib/mysql
  2. mysqld --initialize --user=mysql
  3. service mysqld restart
  4. grep 'temporary password' /var/log/mysqld.log (取得臨時密碼)
  5. mysql_secure_installation (重設密碼)
Reference:

沒有留言:

張貼留言