linux升级mysql数据库版本号_Linux 系统下升级 MySQL 数据库

本文提供了一种在Linux系统中从MySQL 5.6.41升级到5.6.43的方法,包括停止服务、备份配置、解压新版本软件包、更新软链接、初始化安装、测试新版本以及恢复配置和启动服务的详细步骤,强调了升级过程中保持版本一致性和数据备份的重要性。
摘要由CSDN通过智能技术生成

有关 MySQL 的安装,详见我的另一篇文章《Linux 系统下安装 MySQL(重新整理)》。

升级 MySQL 时需要注意:

1、发行版本号要与升级前的保持一致,即不应进行跨版本升级,以免升级后出现各种不兼容的问题。

2、升级前做好数据备份,以免升级过程中的误操作而导致数据丢失。

这里以 5.6.41 版本的 MySQL 升级到 5.6.43 版本为例,演示 MySQL 的升级过程。

停止 MySQL:

root@RicenOS:~# service mysql stop

移走 /etc/my.cnf 文件:

root@RicenOS:~# mv /etc/my.cnf /opt/

这一步是为了避免在升级过程中,影响到旧的数据。

解压 MySQL 软件包到 /usr/local 目录下:

root@RicenOS:~# tar xvf mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz -C /usr/local/

进入到 /usr/local 目录:

root@RicenOS:~# cd /usr/local/

如果之前的 MySQL 是按照我的另一篇文章《Linux 系统下安装 MySQL(重新整理)》来操作的话,那么这里就比较简单,只需要修改一下 mysql 软链接的指向即可:

root@RicenOS:/usr/local# ln -snf mysql-5.6.43-linux-glibc2.12-x86_64/ mysql

root@RicenOS:/usr/local# ls -l mysql

lrwxrwxrwx 1 root root 36 6月  14 11:56 mysql -> mysql-5.6.43-linux-glibc2.12-x86_64/

如果之前是采用其它方式安装 MySQL 的话,这里一定要跟原 MySQL 的安装目录和数据目录区分开。

进入到 /usr/local/mysql 目录下:

root@RicenOS:/usr/local# cd mysql

进行初始化安装:

root@RicenOS:/usr/local/mysql# scripts/mysql_install_db --user=mysql

测试新版本:

root@RicenOS:/usr/local/mysql# bin/mysqld_safe --user=mysql &

root@RicenOS:/usr/local/mysql# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.6.43 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, 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> exit

Bye

停止 MySQL:

root@RicenOS:/usr/local/mysql# killall mysqld

还原 /etc/my.cnf 文件:

root@RicenOS:/usr/local/mysql# mv /opt/my.cnf /etc/

启动 MySQL:

root@RicenOS:/usr/local/mysql# service mysql start

检测升级结果:

root@RicenOS:/usr/local/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.6.43 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, 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> show databases;

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值