Home Database Mysql Tutorial mysql 5.5 升级到 mysql 5.6_MySQL

mysql 5.5 升级到 mysql 5.6_MySQL

May 30, 2016 pm 05:10 PM
mysql

目前MySQL数据库软件升级到5.6.26版本,主要有两种方法。一种是停机升级,即在现有环境下先停止数据库,然后升级数据库软件版本和数据库版本;另外一种是采用不停机的主从升级(master--slave)方式来升级,也就是现在从库上升级,然后切换主从库,再升级原主库的版本。根据条件和资源情况,我们采取第一种方式升级数据库

 

一、升级前准备

 

1.升级前系统环境检查

 

查找glibc版本:

# ] rpm -qa | grep glibc

glibc-2.5-65

glibc-devel-2.5-65

compat-glibc-2.3.4-2.26

glibc-headers-2.5.65

compat-glibc-headers-2.3.4-2.26

glibc-common-2.5-65

 

查找服务器支撑最大glibc版本:

# ] strings /lib64/libc.so.6 | grep GLIBC_

GLIBC_2.2.5

GLIBC_2.2.6

GLIBC_2.3

GLIBC_2.3.2

GLIBC_2.3.3

GLIBC_2.3.4

GLIBC_2.4

GLIBC_2.5

 

查找已安装数据库版本:

# ] rpm -qa | grep -i mysql

MySQL-server-advanced-5.5.23-1.rhel5

MySQL-client-advanced-5.5.23-1.rhel5

 

(注意:glibc属于比较重要的而且容易被忽略的一个依赖包,根据操作系统版本的不同,所支持最大的glibc版本也不一样。需要检查好要升级服务器的版本和支持最大glibc版本,方便下载安装包。)

 

2.升级前数据库检查

 

查看是否还有其他进程在使用。

mysql -uroot -h127.0.0.1 -P3306 -e 'show processlist;'

 

3.下载安装包

 

MySQL新版本rpm文件:

MySQL-client-5.6.26-1.linux_glibc2.5.x86_64.rpm

MySQL-devel-5.6.26-1.linux_glibc2.5.x86_64.rpm

MySQL-server-5.6.26-1.linux_glibc2.5.x86_64.rpm

MySQL-embedded-5.6.26-1.linux_glibc2.5.x86_64.rpm

MySQL-shared-5.6.26-1.linux_glibc2.5.x86_64.rpm

MySQL-shared-compat-5.6.26-1.linux_glibc2.5.x86_64.rpm

MySQL-test-5.6.26-1.linux_glibc2.5.x86_64.rpm

 

4.上传服务器

 

把新版本文件上传至需要升级的服务器。

 

5.使用主机root权限

 

6.打开告警日志、操作日志

 

6.1告警日志

 

通过每个实例的配置文件my.cnf查找告警日志位置。后台打开,并监控。

 

查找告警日志目录:

#] cat /home/mysql/my_cnf/my_3306.cnf | grep "log-error"

后台告警日志:

tail -f /home/mysql/logs/err-log/mysql-err.log

 

6.2操作日志

 

在操作界面打开SecureCRT软件的“会话日志”功能,保存所有操作记录。

 

7备份系统表

 

主要备份数据库系统库:

mysql

performance_schema

information_schema

 

mysqldump备份命令如下:

mysqldump -u root -h127.0.0.1 -P3306 --databases mysql performance_schema information_schema > /home/mysql/20150818.sql

 

二、数据库升级

 

1.停止应用

 

2.停止数据库

mysqladmin --defaults -file=/home/mysql/my_cnf/my_3306.cnf -uroot shutdown

 

3.卸载旧版本数据库

 

本地升级,暂不支持直接升级方案,即直接在原有旧版本基础上更新新版本,需要先卸载旧版本,再安装新版本,通过此方法升级MySQL数据库版本。

 

卸载:

rpm -e MySQL-server-advanced-5.5.23-1.rhel5

rpm -e MySQL-client-advanced-5.5.23-1.rhel5

 

4.升级新版本

 

使用root权限执行下列操作:

rpm -ivh MySQL-client-5.6.26-1.linux_glibc2.5.x86_64.rpm

rpm -ivh MySQL-devel-5.6.26-1.linux_glibc2.5.x86_64.rpm

rpm -ivh MySQL-server-5.6.26-1.linux_glibc2.5.x86_64.rpm

rpm -ivh MySQL-shared-5.6.26-1.linux_glibc2.5.x86_64.rpm

rpm -ivh MySQL-shared-compat-5.6.26-1.linux_glibc2.5.x86_64.rpm

 

5.启动数据库

nohup mysqld_safe --defaults-file=/home/mysql/my_cnf/my_3306.cnf &

 

6.升级数据库

 

从低版本5.5.23升级到高版本5.6.26时,由于版本不同,系统数据库的表结构也会不一样,所以在安装新版本结束后启动数据库时,通过后台启动日志,会监控到系统数据库的一些表结构出现问题,可以通过更新表结构语句来解决。

mysql_upgrade --protocol=tcp -P3306

 

按照上述语句,对每个有问题的实例逐一执行。

 

7.重启数据库,测试数据库能够正常启动

 

由于执行升级数据库命令mysql_upgrade,所以需要重启数据库,查看后台日志,确保能够正常启动。

 

停止数据库

mysqladmin --defaults -file=/home/mysql/my_cnf/my_3306.cnf -uroot shutdown

 

启动数据库

nohup mysqld_safe --defaults-file=/home/mysql/my_cnf/my_3306.cnf &

 

8.测试远程连接

 

最后一步需要测试远程连接操作:

mysql -h “hostname” -P 3306 -u”username” -p'password' -e 'show processlist;'

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MySQL: The Ease of Data Management for Beginners MySQL: The Ease of Data Management for Beginners Apr 09, 2025 am 12:07 AM

MySQL is suitable for beginners because it is simple to install, powerful and easy to manage data. 1. Simple installation and configuration, suitable for a variety of operating systems. 2. Support basic operations such as creating databases and tables, inserting, querying, updating and deleting data. 3. Provide advanced functions such as JOIN operations and subqueries. 4. Performance can be improved through indexing, query optimization and table partitioning. 5. Support backup, recovery and security measures to ensure data security and consistency.

Can I retrieve the database password in Navicat? Can I retrieve the database password in Navicat? Apr 08, 2025 pm 09:51 PM

Navicat itself does not store the database password, and can only retrieve the encrypted password. Solution: 1. Check the password manager; 2. Check Navicat's "Remember Password" function; 3. Reset the database password; 4. Contact the database administrator.

MySQL: Simple Concepts for Easy Learning MySQL: Simple Concepts for Easy Learning Apr 10, 2025 am 09:29 AM

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

How to create navicat premium How to create navicat premium Apr 09, 2025 am 07:09 AM

Create a database using Navicat Premium: Connect to the database server and enter the connection parameters. Right-click on the server and select Create Database. Enter the name of the new database and the specified character set and collation. Connect to the new database and create the table in the Object Browser. Right-click on the table and select Insert Data to insert the data.

How to view database password in Navicat for MariaDB? How to view database password in Navicat for MariaDB? Apr 08, 2025 pm 09:18 PM

Navicat for MariaDB cannot view the database password directly because the password is stored in encrypted form. To ensure the database security, there are three ways to reset your password: reset your password through Navicat and set a complex password. View the configuration file (not recommended, high risk). Use system command line tools (not recommended, you need to be proficient in command line tools).

MySQL and SQL: Essential Skills for Developers MySQL and SQL: Essential Skills for Developers Apr 10, 2025 am 09:30 AM

MySQL and SQL are essential skills for developers. 1.MySQL is an open source relational database management system, and SQL is the standard language used to manage and operate databases. 2.MySQL supports multiple storage engines through efficient data storage and retrieval functions, and SQL completes complex data operations through simple statements. 3. Examples of usage include basic queries and advanced queries, such as filtering and sorting by condition. 4. Common errors include syntax errors and performance issues, which can be optimized by checking SQL statements and using EXPLAIN commands. 5. Performance optimization techniques include using indexes, avoiding full table scanning, optimizing JOIN operations and improving code readability.

How to create a new connection to mysql in navicat How to create a new connection to mysql in navicat Apr 09, 2025 am 07:21 AM

You can create a new MySQL connection in Navicat by following the steps: Open the application and select New Connection (Ctrl N). Select "MySQL" as the connection type. Enter the hostname/IP address, port, username, and password. (Optional) Configure advanced options. Save the connection and enter the connection name.

How to execute sql in navicat How to execute sql in navicat Apr 08, 2025 pm 11:42 PM

Steps to perform SQL in Navicat: Connect to the database. Create a SQL Editor window. Write SQL queries or scripts. Click the Run button to execute a query or script. View the results (if the query is executed).

See all articles