将MySql从Windows Server移到Linux [英] Moving MySql from windows server to linux

查看:73
本文介绍了将MySql从Windows Server移到Linux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从旧的Win2003服务器移动到新的VM服务器(我们选择的Win或Linux) 如果我们使用Linux,转换当前表是否会有任何问题?

Moving from an old Win2003 server to a new VM server (our choice Win or Linux) if we go Linux would there be any problems converting the current tables?

推荐答案

将MySQL/Windows移至相同版本的MySQL/Linux

您可以如下对mysqldump的所有数据库进行转储:

Moving MySQL/Windows to same version of MySQL/Linux

You can mysqldump all the databases as follows:

C:\> mysqldump -uroot -p --routines --triggers --flush-privileges --all-databases > MySQLData.sql

MySQLData.sql移至Linux框中并运行重新加载

Move MySQLData.sql to Linux box and run the reload

mysql -uroot -p < MySQLData.sql

将MySQL/Windows移至更高版本的MySQL/Linux

除了mysql SCHEMA之外,您还可以mysqldump所有数据库!为什么?

Moving MySQL/Windows to higher version of MySQL/Linux

You can mysqldump all the databases EXCEPT THE mysql SCHEMA !!! Why?

  • MySQL在名为mysql.user的主表中为用户授予权限.
  • 对于MySQL的每个主要发行版,mysql.user具有以下列数:
    • MySQL 5.6中的
    • 43列
    • MySQL 5.5中的42个列
    • MySQL 5.1中的39个列
    • MySQL 5.0中的37个列
    • MySQL 4.0/4.1中的31列
    • MySQL has the grants for the user in a main table called mysql.user.
    • For each major release of MySQL, mysql.user has the following number of columns:
      • 43 columns in MySQL 5.6
      • 42 columns in MySQL 5.5
      • 39 columns in MySQL 5.1
      • 37 columns in MySQL 5.0
      • 31 columns in MySQL 4.0/4.1
      • May 01, 2013 : Can I find out what version of MySQL from the data files?
      • Dec 24, 2012 : Backup and restore "mysql" database
      • Jun 13, 2012 : Fastest way to move a database from one server to another
      • Feb 08, 2012 : will replication from 5.5.20 to 5.0.XX server work?

      这是Windows批处理脚本,用于mysqldump除mysql模式以外的所有数据库,然后以纯SQL格式转储mysql模式:

      Here is a Windows Batch Script to mysqldump all databases except the mysql schema and then dump the mysql schema in pure SQL:

      rem
      rem Startup Settings
      rem
      set MYSQL_CONN=-uroot -prootpassword
      set MYSQLDUMP_OUTPUT=C:\LocalDump.sql
      set MYSQL_USERGRANTS=C:\LocalGrants.sql
      set MYSQL_TEMPGRANTS=C:\TempGrants.sql
      rem
      rem Get MySQL User Data
      rem
      set MYSQLDUMP_OPTIONS=--routines --triggers --databases
      set SQLSTMT=SELECT CONCAT('mysqldump %MYSQL_CONN% %MYSQLDUMP_OPTIONS% ',DBList)
      set SQLSTMT=%SQLSTMT% FROM (SELECT GROUP_CONCAT(schema_name SEPARATOR ' ') DBList
      set SQLSTMT=%SQLSTMT% FROM information_schema.schemata WHERE schema_name NOT IN
      set SQLSTMT=%SQLSTMT% ('information_schema','mysql','performance_schema')) A
      echo echo off > C:\RunLocalDump.bat
      mysql %MYSQL_CONN% -ANe"%SQLSTMT%" >> C:\RunLocalDump.bat
      C:\RunLocalDump.bat > %MYSQLDUMP_OUTPUT%
      rem
      rem Get MySQL User Grants
      rem
      set SQLSTMT=SELECT CONCAT('SHOW GRANTS FOR ''',user,'''@''',host,''';')
      set SQLSTMT=%SQLSTMT% FROM mysql.user WHERE LENGTH(user)
      echo %SQLSTMT%
      mysql %MYSQL_CONN% -ANe"%SQLSTMT%" > %MYSQL_TEMPGRANTS%
      mysql %MYSQL_CONN% -AN < %MYSQL_TEMPGRANTS% > %MYSQL_USERGRANTS%
      del %MYSQL_TEMPGRANTS%
      

      一旦创建了mysqldump和Grants文件,只需将它们复制到Linux Server即可在本地执行它们.首先执行mysqldump.然后,加载赠款.

      Once you create the mysqldump and the Grants File, simply copy them to the Linux Server execute them locally. Execute the mysqldump first. Then, load the grants.

      这篇关于将MySql从Windows Server移到Linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆