一、升级的目的
为什么MySQL升级是必须的? 原因有很多,比如:为了使用新增的特性,基于性能方面的考量, 修复的bug. 但是在没有充分的测试以前就应用到你的应用中是非常危险的, 因为升级可以能会让你的应用不能正常运作- 也可能引起性能的问题. 此外, 我建议你关注MySQL的发布信息和Percona Server - 看看最近的版本有什么变化. 也许在在最新的版本中已修复了某个你正在烦恼的问题.
二、升级的方式
通常情况下,有两中升级方式:
直接升级:安装好新版本数据库后,利用已经存在的数据文件夹,同时运行mysql_upgrade脚本来升级。
SQL 导出: 从一个较老版本的mysql把数据导出,然后恢复到新版本的数据库中。(利用mysqldump工具)。
相比之下,第二种方式更安全些,但是这也会使得升级的过程要慢一些。
理论上讲,最安全的方式是:
导出所有用户的权限
导出所有数据并恢复到新版本数据库中
恢复用户权限到新数据库中
三、升级的步骤
1、安装percona server 5.5
[root@cent65 percona-55]# uname -a
Linux cent65 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@cent65 ~]# cd /home/mysql/percona-55/
[root@cent65 percona-55]# ls
Percona-Server-55-debuginfo-5.5.46-rel37.5.el6.x86_64.rpm
Percona-Server-client-55-5.5.46-rel37.5.el6.x86_64.rpm
Percona-Server-devel-55-5.5.46-rel37.5.el6.x86_64.rpm
Percona-Server-server-55-5.5.46-rel37.5.el6.x86_64.rpm
Percona-Server-shared-55-5.5.46-rel37.5.el6.x86_64.rpm
Percona-Server-test-55-5.5.46-rel37.5.el6.x86_64.rpm
安装percona server与系统自带的mysql冲突,首先卸载系统自带mysql:
[root@cent65 percona-55]# rpm -ivh *
warning: Percona-Server-55-debuginfo-5.5.46-rel37.5.el6.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID cd2efd2a: NOKEY
error: Failed dependencies:
MySQL conflicts with mysql-5.1.71-1.el6.x86_64
MySQL-server conflicts with mysql-server-5.1.71-1.el6.x86_64
卸载mysql:
[root@cent65 percona-55]# rpm -e mysql-server --nodeps
[root@cent65 percona-55]# rpm -e mysql --nodeps
[root@cent65 percona-55]# rpm -e mysql-devel --nodeps
安装percona server:
[root@cent65 percona-55]# rpm -ivh *
warning: Percona-Server-55-debuginfo-5.5.46-rel37.5.el6.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID cd2efd2a: NOKEY
Preparing... ########################################### [100%]
1:Percona-Server-shared-5########################################### [ 17%]
2:Percona-Server-client-5########################################### [ 33%]
3:Percona-Server-server-5########################################### [ 50%]
151203 10:57:15 [Note] /usr/sbin/mysqld (mysqld 5.5.46-37.5) starting as process 2537 ...
151203 10:57:27 [Note] /usr/sbin/mysqld (mysqld 5.5.46-37.5) starting as process 2546 ...
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h cent65 password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
Please report any problems at
https://bugs.launchpad.net/percona-server/+filebug
Percona recommends that all production deployments be protected with a support
contract () to ensure the highest uptime,
be eligible for hot fixes, and boost your team's productivity.
Percona Server is distributed with several useful UDF (User Defined Function) from Percona Toolkit.
Run the following commands to create these functions:
mysql -e "CREATE FUNCTION fnv1a_64 RETURNS INTEGER SONAME 'libfnv1a_udf.so'"
mysql -e "CREATE FUNCTION fnv_64 RETURNS INTEGER SONAME 'libfnv_udf.so'"
mysql -e "CREATE FUNCTION murmur_hash RETURNS INTEGER SONAME 'libmurmur_udf.so'"
See for more details
4:Percona-Server-test-55 ########################################### [ 67%]
5:Percona-Server-devel-55########################################### [ 83%]
6:Percona-Server-55-debug########################################### [100%]
----安装成功 !
2、启动mysql server
[root@cent65 percona-55]# service mysql start
Starting MySQL (Percona Server)....[ OK ]
[root@cent65 percona-55]# netstat -an |grep :3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
修改用户口令:
[root@cent65 percona-55]# mysqladmin -u root password "Oracle"
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
连接mysql server:
[root@cent65 percona-55]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.5.46-37.5 Percona Server (GPL), Release 37.5, Revision 684ce54
Copyright (c) 2009-2015 Percona LLC and/or its affiliates
Copyright (c) 2000, 2015, 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.