linux中的mysql5.6升级到5.7
2016-12-14 18:36
591 查看
公司服务器使用的是5.6版本mysql,然后要升级到5.7,然而公司的mysql是使用rpm包安装的mysql,于是我在网上各种搜索mysql升级,终于在网上找到了一篇文章下面是文章的地址,(我是在参考人家的基础上升级的)
注意: 我的是rpm安装的5.6升级到5.7,使用的是编译方法。如果您的mysql低版本是编译方法升级的话可以用以下链接地址
这是我参考的原文章地址:http://suifu.blog.51cto.com/9167728/1863807?utm_source=tuicool&utm_medium=referral
利用mysqldump来直接导出sql文件,导入到新库中,这种方法是最省事儿的,也是最保险的,缺点的话,也显而易见,大库的mysqldump费时费力。
直接替换掉mysql的安装目录和my.cnf,利用mysql_upgrade
来完成系统表的升级,这种方法需要备份原有的文件,但属于物理拷贝,速度较快。缺点的话,跨版本升级不推荐这么做,比如mysql5.1升级到mysql5.6,mysql5.5升级到mysql5.7等。
我的方法是参考第二种方法升级,用5.7的改掉rpm安装的5.6的mysql文件路径,修改相应的/etc/my.cnf,/etc/init.d/mysql和/etc/init.d/mysqld
客户端程序和脚本:/usr/bin
my.cnf位置:/etc/my.cnf
数据库文件目录:/var/lib/mysql
升级前的mysql版本
3.2、备份:/etc/my.cnf
3.3、解压:
3.4、停止mysql
3.5、移动:把解压好的mysql移动到/usr/local/中
3.6、 编译/etc/my.cnf
根据自己的情况添加my.cnf配置
3.7、配置编译/etc/init.d/mysqld
3.8、启动mysql
升级成功,然后再升级字典,否则会在错误日志中看到很多错误
3.9、升级字典
—如果升级报错的话,检查自己的my.cnf文件,看其中是否有自己不需要的配置,我的就是里面有多余的配置,注释或删掉就可
- 3.10、重启mysql
升级后的版本
然后可以删除掉其中的以前5.6的mysql文件夹(我只删掉查出来的,没有详细删)
/usr/lib64/mysql
/usr/include/mysql
/usr/bin/mysql
/usr/share/man/man1/mysql.1.gz
自己研究的,用navicat也连接测试,能连接到,如果连接不上则执行:
进行赋权,还有就是开房3306端口
如果启动mysql报缺少pid文件什么的,可以去网上搜下,如果网上的方法都不行的话就尝试删除数据库文件目录中的 ib_logfile0、ib_logfile1 这两个文件,我的有次就是这样解决了
注意: 我的是rpm安装的5.6升级到5.7,使用的是编译方法。如果您的mysql低版本是编译方法升级的话可以用以下链接地址
这是我参考的原文章地址:http://suifu.blog.51cto.com/9167728/1863807?utm_source=tuicool&utm_medium=referral
1、 升级方法
升级的方法一般有两类:利用mysqldump来直接导出sql文件,导入到新库中,这种方法是最省事儿的,也是最保险的,缺点的话,也显而易见,大库的mysqldump费时费力。
直接替换掉mysql的安装目录和my.cnf,利用mysql_upgrade
来完成系统表的升级,这种方法需要备份原有的文件,但属于物理拷贝,速度较快。缺点的话,跨版本升级不推荐这么做,比如mysql5.1升级到mysql5.6,mysql5.5升级到mysql5.7等。
我的方法是参考第二种方法升级,用5.7的改掉rpm安装的5.6的mysql文件路径,修改相应的/etc/my.cnf,/etc/init.d/mysql和/etc/init.d/mysqld
2、rpm安装mysql5.6的环境
客户端程序和脚本:/usr/bin
my.cnf位置:/etc/my.cnf
数据库文件目录:/var/lib/mysql
升级前的mysql版本
[root@localhost ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 341458 Server version: 5.6.31-log MySQL Community Server (GPL) Copyright (c) 2000, 2016, 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> select version(); +------------+ | version() | +------------+ | 5.6.31-log | +------------+ 1 row in set (0.00 sec)
3、开始 升级
3.1、去官网下载最新5.7版本mysql 选则 Linux-Generic 通用类型 mysql下载地址 我选择的x86_64的,下载后用ftp上传到服务器你的放文件的文件夹中3.2、备份:/etc/my.cnf
[root@localhost home]# cp /etc/my.cnf /etc/my_56.cnf
3.3、解压:
[root@localhost home]# tar -zxvf mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
3.4、停止mysql
[root@localhost home]# service mysql stop
3.5、移动:把解压好的mysql移动到/usr/local/中
[root@localhost home]# mv mysql-5.7.16-linux-glibc2.5-x86_64 /usr/local/mysql [root@localhost home]# chown -R mysql. /usr/local/mysql [root@localhost home]# cd /usr/local/mysql/ [root@localhost mysql]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf [root@localhost mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
3.6、 编译/etc/my.cnf
[client] port=3306 socket=/var/lib/mysql/mysql.sock #你的sock文件目录 default-character-set=utf8 [mysql] no-auto-rehash default-character-set=utf8 [mysqld] port=3306 character-set-server=utf8 socket=/var/lib/mysql/mysql.sock #你的sock文件目录 basedir=/usr/local/mysql datadir=/var/lib/mysql #你的数据库文件目录 sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION [mysqldump] quick max_allowed_packet=32M [myisamchk] key_buffer=16M sort_buffer_size=16M read_buffer=8M write_buffer=8M [mysqld_safe] open-files-limit=8192 log-error=/var/lib/mysql/error.log #你的错误日志文件目录 #pid-file=/data/mysql/mysqld.pid #你的pid文件目录,我的没配置
根据自己的情况添加my.cnf配置
3.7、配置编译/etc/init.d/mysqld
#datadir=/usr/local/mysql/data #修改成你的数据库文件目录 datadir=/var/lib/mysql
3.8、启动mysql
[root@localhost mysql]# /etc/init.d/msyqld start [root@localhost support-files]# ps -ef|grep mysql root 6966 1 0 Dec14 pts/1 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.pid mysql 7168 6966 0 Dec14 pts/1 00:00:13 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/var/lib/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/lib/mysql/error.log --open-files-limit=8192 --pid-file=/var/lib/mysql/localhost.pid --socket=/var/lib/mysql/mysql.sock --port=3306 root 7270 7244 0 00:27 pts/2 00:00:00 vim mysql.server root 7287 6165 0 01:49 pts/1 00:00:00 grep mysql
升级成功,然后再升级字典,否则会在错误日志中看到很多错误
3.9、升级字典
[root@localhost mysql]# /usr/local/mysql/bin/mysql_upgrade -uroot -pMANAGER mysql_upgrade: [Warning] Using a password on the command line interface can be insecure. Checking if update is needed. Checking server version. Running queries to upgrade MySQL server. Checking system database. mysql.columns_priv OK mysql.db OK mysql.engine_cost OK mysql.event OK mysql.func OK mysql.general_log OK mysql.gtid_executed OK mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK mysql.help_topic OK mysql.innodb_index_stats OK mysql.innodb_table_stats OK mysql.ndb_binlog_index OK mysql.plugin OK mysql.proc OK mysql.procs_priv OK mysql.proxies_priv OK mysql.server_cost OK mysql.servers OK mysql.slave_master_info OK mysql.slave_relay_log_info OK mysql.slave_worker_info OK mysql.slow_log OK mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK mysql.time_zone_name OK mysql.time_zone_transition OK mysql.time_zone_transition_type OK mysql.user OK Upgrading the sys schema. Checking databases. helei.helei OK sys.sys_config OK Upgrade process completed successfully. Checking if update is needed.
—如果升级报错的话,检查自己的my.cnf文件,看其中是否有自己不需要的配置,我的就是里面有多余的配置,注释或删掉就可
- 3.10、重启mysql
[root@localhost mysql]# /etc/init.d/mysqld restart Shutting down MySQL.. SUCCESS! Starting MySQL. SUCCESS!
升级后的版本
[root@localhost mysql]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.16 MySQL Community Server (GPL) Copyright (c) 2000, 2016, 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> select version(); +-----------+ | version() | +-----------+ | 5.7.16 | +-----------+ 1 row in set (0.00 sec) mysql>
总结
直接用/etc/my.cnf 中直接指定basedir=/usr/local/mysq 即可然后可以删除掉其中的以前5.6的mysql文件夹(我只删掉查出来的,没有详细删)
/usr/lib64/mysql
/usr/include/mysql
/usr/bin/mysql
/usr/share/man/man1/mysql.1.gz
[root@localhost ~]# whereis mysql mysql: /usr/bin/mysql /usr/local/mysql /usr/lib64/mysql /usr/include/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
自己研究的,用navicat也连接测试,能连接到,如果连接不上则执行:
mysql> grant all privileges on *.* to 'root'@'%' identified by 'password' with grant option; mysql> flush privileges;
进行赋权,还有就是开房3306端口
如果启动mysql报缺少pid文件什么的,可以去网上搜下,如果网上的方法都不行的话就尝试删除数据库文件目录中的 ib_logfile0、ib_logfile1 这两个文件,我的有次就是这样解决了
相关文章推荐
- linux mysql 5.5升级到5.6 使用MySQL的APT库
- 复制环境下mysql5.6升级到5.7
- mysql5.6升级到mysql5.7
- 【MySQL】Linux下MySQL 5.5、5.6和5.7的RPM、二进制和源码安装
- MySQL 5.6升级至MySQL 5.7--------版本升级最佳实战
- linux下安装升级mysql到新版本(5.1-5.7)
- CentOS下mysql5.6升级5.7指南
- Win下Mysql5.6升级到5.7
- CentOS6.5下MySQL5.6升级到MySQL5.7
- Mysql5.6升级到5.7步骤详解
- Linux mysql升级到5.6,安装图形化客户端
- mysql5.6升级到5.7的注意事项
- mysql5.6升级到5.7后Sequel Pro无法连接解决
- Win下Mysql5.6升级到5.7的方法
- mysql 5.6 升级5.7
- linux升级mysql到5.7
- linux升级mysql到5.7
- MySQL版本升级之5.6到5.7
- mysql 5.6 升级 mysql 5.7
- linux上的mysql从5.5升级到5.6