简体   繁体   中英

Moving MySql from windows server to linux

如果我们使用 Linux,从旧的 Win2003 服务器迁移到新的 VM 服务器(我们选择 Win 或 Linux),转换当前表会有什么问题吗?

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

Move MySQLData.sql to Linux box and run the reload

mysql -uroot -p < MySQLData.sql

Moving MySQL/Windows to higher version of MySQL/Linux

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

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%

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.

Give it a Try !!!

You would not need to convert the tables. The SQL dump from the Windows server would be easy to import into MySQL on Linux.

No the tables will be fine. You should also be able to transfer the config files over without issue

using mysqldump and then just the mysql command to restore the backup

You can export your database (tables with data). Then you will get sql script file. If you run that script file in your new system your tables and data will be available in the new system

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM