MySQL 将 .bak 文件转换为 .sql 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12661854/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Convert a .bak file to .sql file
提问by Hamo
I have a aspscript that I'm intending to write it with PHPso I have to get its database and use it.
我有一个ASP脚本,我打算用PHP编写它,所以我必须获取它的数据库并使用它。
I have the database as .bakfile which I understood that it's a backup and I wanna change it to be .sqlto import it in phpMyAdmin
我将数据库作为.bak文件,我知道它是一个备份,我想将其更改为.sql以将其导入 phpMyAdmin
I read about this matter in the web but I didn't find an accurate tutorial that goes through the whole process.
我在网上阅读了有关此问题的信息,但没有找到贯穿整个过程的准确教程。
They are talking about mssqldatabase but I didn't even reach this step..
他们在谈论mssql数据库,但我什至没有达到这一步..
Any help will be highly appreciated. Thanks in advance :)
任何帮助将不胜感激。提前致谢 :)
采纳答案by Hogan
Note, all of this applies to MS SQL because .bak is a usually a MS SQL backup.
请注意,所有这些都适用于 MS SQL,因为 .bak 通常是 MS SQL 备份。
A .bak can't be converted to SQL directly -- it contains a backup of a database which does not have a clear relationship to SQL.
.bak 不能直接转换为 SQL——它包含一个与 SQL 没有明确关系的数据库的备份。
You could restore the backup and then use SQL Server tools and then use that to make some SQL to recreate the SQL server objects but not the dat.
您可以恢复备份,然后使用 SQL Server 工具,然后使用它来创建一些 SQL 来重新创建 SQL Server 对象而不是数据。
From SQL Server Management Studio: Datbases item, right click "Restore Database" then from datbase right click script database.
从 SQL Server Management Studio:数据库项,右键单击“还原数据库”,然后从数据库右键单击脚本数据库。
This won't script the data.
这不会编写数据脚本。
The other option is to use RedGate's excellent tools, which should do everything you want.
另一种选择是使用 RedGate 的优秀工具,它应该可以做你想做的一切。
http://www.red-gate.com/products/sql-development/sql-toolbelt/
http://www.red-gate.com/products/sql-development/sql-toolbelt/
回答by a_horse_with_no_name
Most probably the .bak file is indeed a binary backup of a Microsoft SQL Server database (which is something completely different than MySQL).
最有可能的 .bak 文件确实是 Microsoft SQL Server 数据库(与 MySQL 完全不同的东西)的二进制备份。
So you will first need to install Microsoft SQL Server (Express) together with the SQL Server Management studio (I think there is a bundled download "SQL Server Express including Tools".
因此,您首先需要安装 Microsoft SQL Server (Express) 和 SQL Server Management Studio(我认为有捆绑下载“SQL Server Express 包括工具”。
In the Management Studio you can then import the .bak file into a new database. Once the import is finished you can use it to create SQL script out of the database.
在 Management Studio 中,您可以将 .bak 文件导入到新数据库中。导入完成后,您可以使用它从数据库中创建 SQL 脚本。