mysql数据库升级-5.7.29-5.7.30 RPM包升级
由于我们安装mysql的方式是通过mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar中的rpm包安装:rpm -Uvh mysql-community-*.rpm。注意:当从5.7.29升级到5.7.30需要更新,当升级到最新的5.7.30后,就不用了.当然,如果非要更新(其实没必要),要加--force选项.第二步:创建一个新目录,解压mysql-5.7.30-1.
mysql版本5.7.29升级到5.7.30
由于我们安装mysql的方式是通过mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar中的rpm包安装:
rpm -Uvh mysql-community-*.rpm
所以升级的方式是专门针对这种方式的.
其实升级的过程跟从0开始安装的过程类似.
1 第一步:查看当前的安装版本
方式一:mysql -V
方式二:rpm -qa |grep -i mysql
2 第二步:创建一个新目录,解压mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar到新目录中.10个rpm包.、
第三步:备份数据库,以防升级失败
3.1 备份
mysqldump -u root -p --add-drop-table --routines --events --all-databases --force > data-for-upgrade.sql
3.2 设置参数使数据库关闭时会清空缓存避免版本间缓存格式差异
mysql -u root -p --execute="SET GLOBAL innodb_fast_shutdown=0"
3.3 关闭数据库(如果在升级安装开始时MySQL服务器正在运行,则会在安装结束时自动重启,执行上述升级命令后,可直接查看版本号变为升级后的版本号)
systemctl stop msyqld
第四步:升级:直接替换二进制文件(即直接yum update/rpm -Uvh升级rpm包)数据库目录等都不变
cd 目录/
rpm -Uvh mysql-community-*.rpm
yum update -y *.rpm --操作只更新了软件不影响datadir内容。
第五步:检查并可能解决旧数据和升级软件之间的任何不兼容性
service mysqld strat
mysql_upgrade -uroot -p
注意:当从5.7.29升级到5.7.30需要更新,当升级到最新的5.7.30后,就不用了.当然,如果非要更新(其实没必要),要加--force选项.
第六步:验证
6.1 rpm验证
rpm -qa |grep -i mysql
6.2 mysql命令
mysql -V
6.3 进入msyql系统后验证
mysql> select version();
最后,如果不放心,可以再次重新启动下mysql
systemctl restart mysqld
第七步:升级实战案例1
1 看进程
标准的rpm包安装
[root@edsp ~]# ps -ef|grep mysqld
root 34481 1 0 15:26 pts/0 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
mysql 34934 34481 2 15:26 pts/0 00:00:01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=edsp.err --open-files-limit=12000 --pid-
file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root 35252 34334 0 15:27 pts/0 00:00:00 grep mysqld
确定关闭方式与启动方式
[root@edsp ~]# service mysqld status
mysqld (pid 52156) 正在运行..
备份mysql数据
mysqldump -uroot -p --add-drop-table --routines --events --all-databases --force >/home/4atb/data-for-upgrade.sql
上传安装包并解压
[root@edsp mysql5741]# rpm -qa|grep mysql
mysql-community-embedded-devel-5.7.19-1.el6.x86_64
mysql-community-server-5.7.19-1.el6.x86_64
mysql-community-libs-compat-5.7.19-1.el6.x86_64
mysql-community-libs-5.7.19-1.el6.x86_64
mysql-community-embedded-5.7.19-1.el6.x86_64
mysql-community-devel-5.7.19-1.el6.x86_64
mysql-community-client-5.7.19-1.el6.x86_64
mysql-community-common-5.7.19-1.el6.x86_64
[root@edsp mysql5741]#
[root@edsp mysql5741]# ls -lrt
总用量 492600
-rw-r--r-- 1 7155 31415 28525756 12月 10 00:17 mysql-community-client-5.7.41-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 379720 12月 10 00:17 mysql-community-common-5.7.41-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 4360328 12月 10 00:17 mysql-community-devel-5.7.41-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 40026188 12月 10 00:17 mysql-community-embedded-5.7.41-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 139762956 12月 10 00:17 mysql-community-embedded-devel-5.7.41-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 2772832 12月 10 00:17 mysql-community-libs-5.7.41-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 1761480 12月 10 00:17 mysql-community-libs-compat-5.7.41-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 174353820 12月 10 00:17 mysql-community-server-5.7.41-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 112451104 12月 10 00:18 mysql-community-test-5.7.41-1.el6.x86_64.rpm
关闭mysql并使用yum升级
yum update *.rpm -y
以下为yum升级日志
[root@edsp mysql5741]# rm mysql-community-test-5.7.41-1.el6.x86_64.rpm
rm:是否删除普通文件 "mysql-community-test-5.7.41-1.el6.x86_64.rpm"?y
[root@edsp mysql5741]# ls
mysql-community-client-5.7.41-1.el6.x86_64.rpm mysql-community-devel-5.7.41-1.el6.x86_64.rpm mysql-community-embedded-devel-5.7.41-1.el6.x86_64.rpm mysql-community-libs-compat-5.7.41-1.el6.x86_64.rpm
mysql-community-common-5.7.41-1.el6.x86_64.rpm mysql-community-embedded-5.7.41-1.el6.x86_64.rpm mysql-community-libs-5.7.41-1.el6.x86_64.rpm mysql-community-server-5.7.41-1.el6.x86_64.rpm
[root@edsp mysql5741]# ls -lrt
总用量 382780
-rw-r--r-- 1 7155 31415 28525756 12月 10 00:17 mysql-community-client-5.7.41-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 379720 12月 10 00:17 mysql-community-common-5.7.41-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 4360328 12月 10 00:17 mysql-community-devel-5.7.41-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 40026188 12月 10 00:17 mysql-community-embedded-5.7.41-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 139762956 12月 10 00:17 mysql-community-embedded-devel-5.7.41-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 2772832 12月 10 00:17 mysql-community-libs-5.7.41-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 1761480 12月 10 00:17 mysql-community-libs-compat-5.7.41-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 174353820 12月 10 00:17 mysql-community-server-5.7.41-1.el6.x86_64.rpm
[root@edsp mysql5741]# yum update -y *.rpm
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
ftp://192.168.200.3/pub/Server/repodata/repomd.xml: [Errno 14] PYCURL ERROR 67 - "Access denied: 530"
Trying other mirror.
Setting up Update Process
Examining mysql-community-client-5.7.41-1.el6.x86_64.rpm: mysql-community-client-5.7.41-1.el6.x86_64
Marking mysql-community-client-5.7.41-1.el6.x86_64.rpm as an update to mysql-community-client-5.7.19-1.el6.x86_64
Examining mysql-community-common-5.7.41-1.el6.x86_64.rpm: mysql-community-common-5.7.41-1.el6.x86_64
Marking mysql-community-common-5.7.41-1.el6.x86_64.rpm as an update to mysql-community-common-5.7.19-1.el6.x86_64
Examining mysql-community-devel-5.7.41-1.el6.x86_64.rpm: mysql-community-devel-5.7.41-1.el6.x86_64
Marking mysql-community-devel-5.7.41-1.el6.x86_64.rpm as an update to mysql-community-devel-5.7.19-1.el6.x86_64
Examining mysql-community-embedded-5.7.41-1.el6.x86_64.rpm: mysql-community-embedded-5.7.41-1.el6.x86_64
Marking mysql-community-embedded-5.7.41-1.el6.x86_64.rpm as an update to mysql-community-embedded-5.7.19-1.el6.x86_64
Examining mysql-community-embedded-devel-5.7.41-1.el6.x86_64.rpm: mysql-community-embedded-devel-5.7.41-1.el6.x86_64
Marking mysql-community-embedded-devel-5.7.41-1.el6.x86_64.rpm as an update to mysql-community-embedded-devel-5.7.19-1.el6.x86_64
Examining mysql-community-libs-5.7.41-1.el6.x86_64.rpm: mysql-community-libs-5.7.41-1.el6.x86_64
Marking mysql-community-libs-5.7.41-1.el6.x86_64.rpm as an update to mysql-community-libs-5.7.19-1.el6.x86_64
Examining mysql-community-libs-compat-5.7.41-1.el6.x86_64.rpm: mysql-community-libs-compat-5.7.41-1.el6.x86_64
Marking mysql-community-libs-compat-5.7.41-1.el6.x86_64.rpm as an update to mysql-community-libs-compat-5.7.19-1.el6.x86_64
Examining mysql-community-server-5.7.41-1.el6.x86_64.rpm: mysql-community-server-5.7.41-1.el6.x86_64
Marking mysql-community-server-5.7.41-1.el6.x86_64.rpm as an update to mysql-community-server-5.7.19-1.el6.x86_64
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.19-1.el6 will be updated
---> Package mysql-community-client.x86_64 0:5.7.41-1.el6 will be an update
---> Package mysql-community-common.x86_64 0:5.7.19-1.el6 will be updated
---> Package mysql-community-common.x86_64 0:5.7.41-1.el6 will be an update
---> Package mysql-community-devel.x86_64 0:5.7.19-1.el6 will be updated
---> Package mysql-community-devel.x86_64 0:5.7.41-1.el6 will be an update
---> Package mysql-community-embedded.x86_64 0:5.7.19-1.el6 will be updated
---> Package mysql-community-embedded.x86_64 0:5.7.41-1.el6 will be an update
---> Package mysql-community-embedded-devel.x86_64 0:5.7.19-1.el6 will be updated
---> Package mysql-community-embedded-devel.x86_64 0:5.7.41-1.el6 will be an update
---> Package mysql-community-libs.x86_64 0:5.7.19-1.el6 will be updated
---> Package mysql-community-libs.x86_64 0:5.7.41-1.el6 will be an update
---> Package mysql-community-libs-compat.x86_64 0:5.7.19-1.el6 will be updated
---> Package mysql-community-libs-compat.x86_64 0:5.7.41-1.el6 will be an update
---> Package mysql-community-server.x86_64 0:5.7.19-1.el6 will be updated
---> Package mysql-community-server.x86_64 0:5.7.41-1.el6 will be an update
--> Finished Dependency ResolutionDependencies Resolved
=============================================================================================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================================================================================
Updating:
mysql-community-client x86_64 5.7.41-1.el6 /mysql-community-client-5.7.41-1.el6.x86_64 104 M
mysql-community-common x86_64 5.7.41-1.el6 /mysql-community-common-5.7.41-1.el6.x86_64 2.8 M
mysql-community-devel x86_64 5.7.41-1.el6 /mysql-community-devel-5.7.41-1.el6.x86_64 23 M
mysql-community-embedded x86_64 5.7.41-1.el6 /mysql-community-embedded-5.7.41-1.el6.x86_64 211 M
mysql-community-embedded-devel x86_64 5.7.41-1.el6 /mysql-community-embedded-devel-5.7.41-1.el6.x86_64 953 M
mysql-community-libs x86_64 5.7.41-1.el6 /mysql-community-libs-5.7.41-1.el6.x86_64 9.8 M
mysql-community-libs-compat x86_64 5.7.41-1.el6 /mysql-community-libs-compat-5.7.41-1.el6.x86_64 5.6 M
mysql-community-server x86_64 5.7.41-1.el6 /mysql-community-server-5.7.41-1.el6.x86_64 804 MTransaction Summary
=============================================================================================================================================================================================================================================
Upgrade 8 Package(s)Total size: 2.1 G
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
akonadi-1.2.1-2.el6.x86_64 has missing requires of qt4-mysql
Updating : mysql-community-common-5.7.41-1.el6.x86_64 1/16
Updating : mysql-community-libs-5.7.41-1.el6.x86_64 2/16
Updating : mysql-community-client-5.7.41-1.el6.x86_64 3/16
Updating : mysql-community-devel-5.7.41-1.el6.x86_64 4/16
Updating : mysql-community-embedded-5.7.41-1.el6.x86_64 5/16
Updating : mysql-community-embedded-devel-5.7.41-1.el6.x86_64 6/16
Updating : mysql-community-server-5.7.41-1.el6.x86_64 7/16
Updating : mysql-community-libs-compat-5.7.41-1.el6.x86_64 8/16
Cleanup : mysql-community-embedded-devel-5.7.19-1.el6.x86_64 9/16
Cleanup : mysql-community-server-5.7.19-1.el6.x86_64 10/16
Cleanup : mysql-community-devel-5.7.19-1.el6.x86_64 11/16
Cleanup : mysql-community-client-5.7.19-1.el6.x86_64 12/16
Cleanup : mysql-community-embedded-5.7.19-1.el6.x86_64 13/16
Cleanup : mysql-community-libs-compat-5.7.19-1.el6.x86_64 14/16
Cleanup : mysql-community-libs-5.7.19-1.el6.x86_64 15/16
Cleanup : mysql-community-common-5.7.19-1.el6.x86_64 16/16
Verifying : mysql-community-server-5.7.41-1.el6.x86_64 1/16
Verifying : mysql-community-common-5.7.41-1.el6.x86_64 2/16
Verifying : mysql-community-libs-compat-5.7.41-1.el6.x86_64 3/16
Verifying : mysql-community-libs-5.7.41-1.el6.x86_64 4/16
Verifying : mysql-community-embedded-devel-5.7.41-1.el6.x86_64 5/16
Verifying : mysql-community-embedded-5.7.41-1.el6.x86_64 6/16
Verifying : mysql-community-client-5.7.41-1.el6.x86_64 7/16
Verifying : mysql-community-devel-5.7.41-1.el6.x86_64 8/16
Verifying : mysql-community-embedded-devel-5.7.19-1.el6.x86_64 9/16
Verifying : mysql-community-libs-compat-5.7.19-1.el6.x86_64 10/16
Verifying : mysql-community-common-5.7.19-1.el6.x86_64 11/16
Verifying : mysql-community-embedded-5.7.19-1.el6.x86_64 12/16
Verifying : mysql-community-server-5.7.19-1.el6.x86_64 13/16
Verifying : mysql-community-devel-5.7.19-1.el6.x86_64 14/16
Verifying : mysql-community-libs-5.7.19-1.el6.x86_64 15/16
Verifying : mysql-community-client-5.7.19-1.el6.x86_64 16/16Updated:
mysql-community-client.x86_64 0:5.7.41-1.el6 mysql-community-common.x86_64 0:5.7.41-1.el6 mysql-community-devel.x86_64 0:5.7.41-1.el6 mysql-community-embedded.x86_64 0:5.7.41-1.el6
mysql-community-embedded-devel.x86_64 0:5.7.41-1.el6 mysql-community-libs.x86_64 0:5.7.41-1.el6 mysql-community-libs-compat.x86_64 0:5.7.41-1.el6 mysql-community-server.x86_64 0:5.7.41-1.el6Complete!
启动mysql并进行数据字典表以及系统表升级
[root@edsp mysql5741]# service mysqld start
正在启动 mysqld: [确定][root@edsp mysql5741]# mysql -V
mysql Ver 14.14 Distrib 5.7.41, for Linux (x86_64) using EditLine wrapper
[root@edsp mysql5741]# service mysqld stop
停止 mysqld: [确定]
[root@edsp mysql5741]# service mysqld start
正在启动 mysqld: [确定]
[root@edsp mysql5741]# mysql_upgrade -uroot -p
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)