Tutorial on migrating mysql from phpstudy to Linux

Tutorial on migrating mysql from phpstudy to Linux

Project Purpose

Migrate the data in MySQL 5.5.53 built with phpstudy in the original Windows environment to the new host Linux environment

Environmental conditions

New host system platform:

CentOS release 7.4 (Final) kernel 3.10.0-693.el7.x86_64

mysql environment:

mysql> status
Server version: 5.6.39-log MySQL Community Server (GPL)
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8

mysql> show variables like '%storage_engine%';
+----------------------------+--------+
| Variable_name | Value |
+----------------------------+--------+
| default_storage_engine | InnoDB |
| default_tmp_storage_engine | InnoDB |
| storage_engine | InnoDB |
+----------------------------+--------+

Old host:
System Platform:

Windows 2012 R2 SE X64

mysql environment:

Server version: 5.5.53 MySQL Community Server (GPL)
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8

mysql> show variables like '%storage_engine%';
+------------------------+--------+
| Variable_name | Value |
+------------------------+--------+
| default_storage_engine | MyISAM |
| storage_engine | MyISAM |
+------------------------+--------+

The storage engine of the table

mysql> show table status from database\G;
Engine: InnoDB
Engine: MyISAM

Migration Process

1. Use phpstudy's own tools to export each database

image

I saw that mysqldump was also used for the operation.

2. If you just want to keep the original table engine, you can do the following

mysql> create database zentao;
mysql> use zentao;
mysql> source zentao20180413161534.sql;
mysql> show tables;
+-------------------+
| Tables_in_zentao |
+-------------------+
| zt_action |
| zt_bug |
| zt_build |
...

The original table engine remains intact.

mysql> show table status from zentao\G;
*************************** 1. row ***************************
Name: zt_action
Engine: MyISAM
Version: 10
Row_format: Dynamic

3. Change the table engine in the original database to InnoDB

Find ENGINE=MyISAM in the exported table structure zentao.sql and change it to ENGINE=InnoDB. As for how you replace it, it depends on your preference.

# vim zentao.sql
:%s/ENGINE=MyISAM/ENGINE=InnoDB/g

4. Import data into the specified database

mysql> use zentao;
mysql> source zentao.sql;

Changed the table engine to InnoDB

mysql> show table status from zentao\G;
*************************** 1. row ***************************
Name: zt_action
Engine: InnoDB
Version: 10
Row_format: Compact

5. But there is a problem. When checking the detailed information of the table, it is found that Data_free is not zero, indicating that there is data fragmentation and needs to be optimized.

mysql> select table_schema, table_name, data_free, engine from information_schema.tables where table_schema not in ('information_schema', 'mysql') and data_free != 0;
+--------------+------------+-----------+--------+
| table_schema | table_name | data_free | engine |
+--------------+------------+-----------+--------+
| zentao | zt_bug | 4194304 | InnoDB |
| zentao | zt_history | 4194304 | InnoDB |
+--------------+------------+-----------+--------+

6. Defragment the table

mysql> use zentao;
mysql> optimize table zt_bug,zt_history;
+-------------------+----------+----------+-------------------------------------------------------------------+
| Table | Op | Msg_type | Msg_text |
+-------------------+----------+----------+-------------------------------------------------------------------+
| zentao.zt_bug | optimize | note | Table does not support optimize, doing recreate + analyze instead |
| zentao.zt_bug | optimize | status | OK |
| zentao.zt_history | optimize | note | Table does not support optimize, doing recreate + analyze instead |
| zentao.zt_history | optimize | status | OK |
+-------------------+----------+----------+-------------------------------------------------------------------+

It prompts that the table does not support optimize, but it shows OK below. In fact, it has been executed successfully. Version 5.6.X actually supports Innodb

mysql> select table_name,engine,table_rows,data_length+index_length length,DATA_FREE from information_schema.tables where TABLE_SCHEMA='zentao' and data_free =0;
+-------------------+--------+------------+---------+-----------+
| table_name | engine | table_rows | length | DATA_FREE |
+-------------------+--------+------------+---------+-----------+
| zt_bug | InnoDB | 1018 | 1589248 | 0 |
| zt_history | InnoDB | 2584 | 1589248 | 0 |

The same operation can be performed for multiple database methods.

You may also be interested in:
  • Perfect solution to mysql cannot start after phpstudy is installed (no need to delete the original database, no need to change any configuration, no need to change the port) direct coexistence
  • phpstudy2018 Tutorial on Upgrading MySQL 5.5 to 5.7 (with pictures and text)
  • How to upgrade MySQL version to 5.7.17 in phpStudy
  • Solve the problem of PhPStudy MySQL startup failure under Windows system

<<:  Detailed explanation of reduce fold unfold usage in JS

>>:  Detailed explanation of redis5 cluster construction and usage under Linux (Centos7)

Recommend

HTML data submission post_PowerNode Java Academy

The HTTP request methods specified by the HTTP/1....

The most common declaration merge in TS (interface merge)

Table of contents 1. Merge interface 1.1 Non-func...

js realizes the image cutting function

This article example shares the specific code of ...

Element uses scripts to automatically build new components

Table of contents background How does element-ui&...

Web interview Vue custom components and calling methods

Import: Due to project requirements, we will enca...

JavaScript event delegation principle

Table of contents 1. What is event delegation? 2....

Vue.js front-end web page pop-up asynchronous behavior example analysis

Table of contents 1. Preface 2. Find two pop-up c...

Javascript Virtual DOM Detailed Explanation

Table of contents What is virtual dom? Why do we ...

Detailed explanation of the concept of docker container layers

Table of contents 01 Container consistency 02 Con...

JavaScript to implement retractable secondary menu

The specific code for implementing the retractabl...

Mariadb remote login configuration and problem solving

Preface: The installation process will not be des...

Detailed explanation of overflow:auto usage

Before starting the main text, I will introduce s...

Detailed explanation of Linx awk introductory tutorial

Awk is an application for processing text files, ...

Use image to submit the form instead of using button to submit the form

Copy code The code is as follows: <form method...

VMware Tools installation and configuration tutorial for Ubuntu

Some time ago, the blogger installed the Ubuntu s...