[root@cent65 mysql]# mysql -uroot -p -BNe "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('mysql', 'performance_schema', 'information_schema')" | tr 'n' ' ' > /home/mysql/dbs-to-dump.sql
Enter password:
查看sql scripts:
[root@cent65 mysql]# cat dbs-to-dump.sql
prod
test
[root@cent65 mysql]# mysqldump -u root -p --routines --events --single-transaction --databases $(cat /home/mysql/dbs-to-dump.sql) > /home/mysql/full-data-dump.sql
Enter password:
[root@cent65 mysql]# cat full-data-dump.sql
-- MySQL dump 10.13 Distrib 5.5.46-37.5, for Linux (x86_64)
--
-- Host: localhost Database: prod
-- ------------------------------------------------------
-- Server version 5.5.46-37.5
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
-- Current Database: `prod`
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `prod` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `prod`;
-- Table structure for table `emp`
DROP TABLE IF EXISTS `emp`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `emp` (
`id` int(11) DEFAULT NULL,
`name` varchar(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
-- Dumping data for table `emp`
LOCK TABLES `emp` WRITE;
/*!40000 ALTER TABLE `emp` DISABLE KEYS */;
INSERT INTO `emp` VALUES (10,'tom'),(20,'jerry'),(30,'rose');
/*!40000 ALTER TABLE `emp` ENABLE KEYS */;
UNLOCK TABLES;
-- Dumping events for database 'prod'
-- Dumping routines for database 'prod'
-- Current Database: `test`
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `test`;
-- Dumping events for database 'test'
-- Dumping routines for database 'test'
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2015-12-03 12:31:52
3)、停止数据库
[root@cent65 mysql]# service mysql stop
Shutting down MySQL (Percona Server).......[ OK ]
[root@cent65 mysql]# mv /var/lib/mysql /var/lib/mysql55
4)、 移动旧数据库(5.5版本)的数据目录(假设是/var/lib/mysql,此处应该改为你自己的数据目录)
[root@cent65 mysql]#mv /var/lib/mysql /var/lib/mysql55
[root@cent65 mysql]#mkdir /var/lib/mysql
[root@cent65 mysql]#chown -R mysql:mysql /var/lib/mysql
三、安装Percona Server 5.6
[root@cent65 percona-56]# ls -l
total 121104
-rwxr-xr-x. 1 mysql mysql 70389368 Dec 3 11:21 Percona-Server-56-debuginfo-5.6.25-rel73.1.el6.x86_64.rpm
-rwxr-xr-x. 1 mysql mysql 6727084 Dec 3 11:21 Percona-Server-client-56-5.6.25-rel73.1.el6.x86_64.rpm
-rwxr-xr-x. 1 mysql mysql 1031588 Dec 3 11:21 Percona-Server-devel-56-5.6.25-rel73.1.el6.x86_64.rpm
-rwxr-xr-x. 1 mysql mysql 20463420 Dec 3 11:21 Percona-Server-server-56-5.6.25-rel73.1.el6.x86_64.rpm
-rwxr-xr-x. 1 mysql mysql 742496 Dec 3 11:21 Percona-Server-shared-56-5.6.25-rel73.1.el6.x86_64.rpm
-rwxr-xr-x. 1 mysql mysql 23137340 Dec 3 11:21 Percona-Server-test-56-5.6.25-rel73.1.el6.x86_64.rpm
-rwxr-xr-x. 1 mysql mysql 1508480 Dec 3 11:21 Percona-Server-tokudb-56-5.6.25-rel73.1.el6.x86_64.rpm
Percona server 5.5会与5.6的软件有冲突,所以5.6的安装需要强制安装:
[root@cent65 percona-56]# rpm -ivh Percona-Server-shared-56-5.6.25-rel73.1.el6.x86_64.rpm --force
warning: Percona-Server-shared-56-5.6.25-rel73.1.el6.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID cd2efd2a: NOKEY
Preparing... ########################################### [100%]
1:Percona-Server-shared-5########################################### [100%]