mysql 5.6 升级5.7

注意:

是一个很好的实践在安装新的软件前备份你的数据库,尽管MySQL 很努力的确保高级别的质量,

通过备份来保护你的数据。


升级5.6到5.7,Mysql 推荐你执行一个2进制的替换升级 使用下面的过程;

1.停止老的(MySQL 5.6)server

2.升级MySQL 2进制的或者包代替(代替5.6的2进制)

3. 启动MySQL 5.7 使用存在的数据目录

4. 运行mysql_update来升级系统表和初始化用于5.7使用



另一种方法是使用本程序执行逻辑升级

1.备份当前数据:

shell> mysqldump --all-databases --routines --events --add-drop-table --flush-privileges=0 > data-for-upgrade.sql


2.停止老的(MySQL 5.6)server

3.安装MySQL 5.7

4.初始化一个新的数据目录

v-lhb-db03:/data5.7/mysql# mysqld --initialize --datadir=/data5.7/mysql/


5. 启动MySQL 使用新的数据目录


运行mysql_upgrate 来升级系统表和初始化




1.备份数据库


2.备份5.6版本的软件

v-lhb-db03:/usr/local# tar -cvf mysql.tar mysql/

删除软件目录rm -rf mysql


3.安装5.7的版本


v-lhb-db03:/root/mysql-5.7.7-rc# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-- Running cmake version 2.8.12.2
-- Could NOT find Git (missing:  GIT_EXECUTABLE) 
-- Configuring with MAX_INDEXES = 64U
-- SIZEOF_VOIDP 8
-- MySQL 5.7.7-rc
-- Packaging as: mysql-5.7.7-rc-Linux-x86_64
-- Looked for boost/version.hpp in  and 
-- BOOST_INCLUDE_DIR BOOST_INCLUDE_DIR-NOTFOUND
-- LOCAL_BOOST_DIR 
-- LOCAL_BOOST_ZIP 
-- Could not find (the correct version of) boost.
-- MySQL currently requires boost_1_57_0

CMake Error at cmake/boost.cmake:76 (MESSAGE):
  You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>

  This CMake script will look for boost in <directory>.  If it is not there,
  it will download and unpack it (in that directory) for you.

  If you are inside a firewall, you may need to use an http proxy:

  export http_proxy=http://example.com:80

Call Stack (most recent call first):
  cmake/boost.cmake:228 (COULD_NOT_FIND_BOOST)
  CMakeLists.txt:452 (INCLUDE)


-- Configuring incomplete, errors occurred!
See also "/root/mysql-5.7.7-rc/CMakeFiles/CMakeOutput.log".




执行直接升级在多余一个的主要版本间(比如 MySQL 5.5 到5.7)。是不推荐和支持的

如果你需要这么做,我们推荐你用2进制升级代替 比如5.5升级到5.7

1.升级Mysql 从5.5升级到5.6

2.用5.6启动 使用存在的数据目录

3.运行mysql_upgrade 来升级系统表和初始化

4.升级MYSQL 从5.6到5.7


5.启动5.7用现在存在的目录

6.运行mysql_upgrade


通常,通过下面的步骤从5.6升级到5.7


阅读所有的细节来确认任何的影响会影响你的应用



项目的改变列表在这个章节可以使你确定升级该注意的

一些不兼容的讨论需要你注意在升级前。其他需要升级后处理


MySQL 5.7 版本描述了显著的新的特性你可以在5.7版本中使用,



变化标记为已知的问题或者不兼容的改变是和早期版本不兼容的,在升级前需要注意。


我们的目标是避免那些改变,但是偶尔的 它们需要收集问题,比不兼容更坏的情况



If you plan to to upgrade using the data directory from your existing MySQL installation:

Stop the old (MySQL 5.6) server

Upgrade the MySQL binaries in place (replace the old binaries with the new ones)

Start the MySQL 5.7 server normally (no special options)

Run mysql_upgrade to upgrade the system tables


Restart the MySQL 5.7 server


-------------------------------------------------------------------------------------------

1.备份数据库


2.备份5.6版本的软件

v-lhb-db03:/usr/local# tar -cvf mysql.tar mysql/

删除软件目录rm -rf mysql


3.安装5.7的版本


v-lhb-db03:/root/mysql-5.7.7-rc# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-- Running cmake version 2.8.12.2
-- Could NOT find Git (missing:  GIT_EXECUTABLE) 
-- Configuring with MAX_INDEXES = 64U
-- SIZEOF_VOIDP 8
-- MySQL 5.7.7-rc
-- Packaging as: mysql-5.7.7-rc-Linux-x86_64
-- Looked for boost/version.hpp in  and 
-- BOOST_INCLUDE_DIR BOOST_INCLUDE_DIR-NOTFOUND
-- LOCAL_BOOST_DIR 
-- LOCAL_BOOST_ZIP 
-- Could not find (the correct version of) boost.
-- MySQL currently requires boost_1_57_0

CMake Error at cmake/boost.cmake:76 (MESSAGE):
  You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>

  This CMake script will look for boost in <directory>.  If it is not there,
  it will download and unpack it (in that directory) for you.

  If you are inside a firewall, you may need to use an http proxy:

  export http_proxy=http://example.com:80

Call Stack (most recent call first):
  cmake/boost.cmake:228 (COULD_NOT_FIND_BOOST)
  CMakeLists.txt:452 (INCLUDE)


-- Configuring incomplete, errors occurred!
See also "/root/mysql-5.7.7-rc/CMakeFiles/CMakeOutput.log".


解决:  从MySQL 5.7.5开始Boost库是必需的,下载Boost库并上传到/usr/local/src下,在解压后复制到/usr/local/boost目录下,然后重新cmake并在后面的选项中加上选项-DWITH_BOOST=/usr/local/boost(下载:
http://sourceforge.net/projects/boost/files/boost/)

需要  Boost minor version found is 58 we need 57,安装boost_1_57_0.tar.gz

v-lhb-db03:/root/boost_1_57_0# mv * /usr/local/boost/

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql  -DWITH_BOOST=/usr/local/boost 

make && make install

chown -R mysql:mysql /usr/local/mysql


zjzc-mysql:/usr/local/mysql# mysql_upgrade  -uroot -p1234567^C
zjzc-mysql:/usr/local/mysql# service mysql start
Starting MySQL....                                         [  OK  ]


zjzc-mysql:/usr/local/mysql# mysql_upgrade -uroot -p1234567


升级完成后,查看版本:
Server version:		5.7.7-rc-log Source distribution

原文地址:https://www.cnblogs.com/hzcya1995/p/13351634.html