mysql 5.5 升级到 mysql 5.6_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;'

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



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.

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 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.

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.

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 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.

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.

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).
