假设原来是mysql 5.6.19社区版,现在要升级到percona server 5.6.30。
对于大的数据库来说,采用mysqldump方式进行迁移太花费时间了,可采用新安装加载原来数据库的方式大大节约升级时间。
对于mysql升级来说,一个主要的步骤就是升级后权限的同步更新以及数据表的校验。
假设原来为/usr/local/mysql-> mysql-5.6.19-linux-glibc2.5-x86_64,数据库在data目录下。
0、停止现有实例,/usr/local/mysql/bin/mysqladmin -u -p shutdown
1、首先,删除原来的符号链接rm rf /usr/local/mysql;
2、解压Percona-Server-5.6.30-rel76.3-Linux.x86_64.ssl101.tar.gz到当前目录;
3、创建新的符号链接ln -s Percona-Server-5.6.30-rel76.3-Linux.x86_64.ssl101 mysql
4、更改my.cnf,去掉datadir、basedir注释,如下:
basedir = /usr/local/mysql #指向最新的mysql实例
datadir = /usr/local/mysql-5.6.19-linux-glibc2.5-x86_64/data 指向原来的mysql数据库目录
其他配置可以保持不变。。。
5、使用新的安装包创建启动mysql实例:/usr/local/mysql/bin/mysqld_safe --user=mysql &
6、执行mysql_upgrade
[root@localhost bin]# ./mysql_upgrade -uroot -p
Warning: Using a password on the command line interface can be insecure.Looking for 'mysql' as: ./mysqlLooking for 'mysqlcheck' as: ./mysqlcheckRunning 'mysqlcheck with default connection argumentsWarning: Using a password on the command line interface can be insecure.Running 'mysqlcheck with default connection argumentsWarning: Using a password on the command line interface can be insecure.mysql.columns_priv OKmysql.db OKmysql.event OKmysql.func OKmysql.general_log OKmysql.help_category OKmysql.help_keyword OKmysql.help_relation OKmysql.help_topic OKmysql.innodb_index_stats OKmysql.innodb_table_stats OKmysql.ndb_binlog_index OKmysql.plugin OKmysql.proc OKmysql.procs_priv OKmysql.proxies_priv OKmysql.servers OKmysql.slave_master_info OKmysql.slave_relay_log_info OKmysql.slave_worker_info OKmysql.slow_log OKmysql.tables_priv OKmysql.time_zone OKmysql.time_zone_leap_second OKmysql.time_zone_name OKmysql.time_zone_transition OKmysql.time_zone_transition_type OKmysql.user OKRunning 'mysql_fix_privilege_tables'...Warning: Using a password on the command line interface can be insecure.Running 'mysqlcheck with default connection argumentsWarning: Using a password on the command line interface can be insecure.Running 'mysqlcheck with default connection argumentsWarning: Using a password on the command line interface can be insecure.mig_db.mig_tab OKmig_db.mig_tab2 OKOK7、重启mysql实例。
8、客户端验证,可发现所有数据和存储过程均正常。