有关 MySQL 的安装,详见我的另一篇文章《Linux 系统下安装 MySQL(重新整理)》。
升级 MySQL 时需要注意:
1、发行版本号要与升级前的保持一致,即不应进行跨版本升级,以免升级后出现各种不兼容的问题。
2、升级前做好数据备份,以免升级过程中的误操作而导致数据丢失。
这里以 5.6.41 版本的 MySQL 升级到 5.6.43 版本为例,演示 MySQL 的升级过程。
停止 MySQL:
移走 /etc/my.cnf 文件:
这一步是为了避免在升级过程中,影响到旧的数据。
解压 MySQL 软件包到 /usr/local 目录下:
进入到 /usr/local 目录:
如果之前的 MySQL 是按照我的另一篇文章《Linux 系统下安装 MySQL(重新整理)》来操作的话,那么这里就比较简单,只需要修改一下 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/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:
还原 /etc/my.cnf 文件:
启动 MySQL:
检测升级结果:
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;
Copyright © 2005-2023 by www.ricensoftwares.com.cn All Rights Reserved.