国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

將phpstudy中的mysql遷移至Linux教程

2024-07-25 19:08:17
字體:
來源:轉載
供稿:網友

項目目的

將原來windows環境中使用phpstudy搭建的mysql 5.5.53 中的數據遷移至新主機Linux環境中

環境情況

新主機
系統平臺:

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

mysql環境:

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

舊主機:
系統平臺:

Windows 2012 R2 SE X64

mysql環境:

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

表的存儲引擎

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

遷移過程

1.使用phpstudy自帶的工具進行每個數據庫導出

image

我看了,也是用的mysqldump操作的。

2.如果只是保留原本的表引擎,那么直接以下操作即可

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

原表引擎保持原樣。

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

3.將原有數據庫中的表引擎變更為InnoDB

在導出的表結構zentao.sql中找到ENGINE=MyISAM,修改成ENGINE=InnoDB,至于你用什么方法替換,看你喜歡了。

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

4.導入數據到指定數據庫

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

表引擎變更為InnoDB

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

5.但是有一個問題,查看表的詳細信息時發現Data_free不為零,說明存在數據碎片,需要進行優化

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.整理有碎片的表

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

提示該表不支持 optimize,但是下邊有顯示OK.其實已經執行成功了。5.6.X的版本,其實已經支持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 |

多個數據庫方法同樣操作即可。


注:相關教程知識閱讀請移步到MYSQL教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 淳化县| 浠水县| 福清市| 昆明市| 定日县| 抚顺县| 兴隆县| 武平县| 五指山市| 通榆县| 新兴县| 南昌县| 武隆县| 天门市| 忻州市| 陆河县| 五常市| 汨罗市| 清镇市| 格尔木市| 吉安市| 镇康县| 昌吉市| 霍林郭勒市| 宁城县| 巩义市| 通海县| 庄河市| 曲阜市| 红河县| 祁连县| 广平县| 波密县| 玉门市| 舒兰市| 永清县| 马尔康县| 察雅县| 建阳市| 金门县| 东乡县|