interbase mysql_InterBase数据库迁移到MySQL(恢复备份)

我拿到的是InterBase导出的“.gbk”后缀的数据库备份文件,目标是可以通过命令行的方式导入到指定的数据库中,在这个脚本中我使用了InterBase数据库中自带的“gbak”命令行来进行操作。

首先来介绍一下这个InterBase数据库吧,http://baike.baidu.com/item/interbase?fr=aladdin——百度百科,大致来说就是一种文件数据库了,而由于我在Ubuntu上找不到对应的安装包,所以就拿InterBase对应的开源版本Firebird数据库来练习了,当然,由于这个程序是在windows平台上运行的,最后的操作我还是在windows7上进行的,只是为了前期的实验方便在Linux上操作了(Linux上包和软件的安装真不是一般的方便额),至于Firebird和InterBase的关系可以看百度百科——http://baike.baidu.com/view/424640.htm?fr=aladdin。

InterBase的bin目录下有个gbak程序负责数据库的备份操作。具体的命令如下:

gbak -c -user "sysdba" -password "masterkey" "%path%\dbanme.gbk" "127.0.0.1:%path%\dbanme.gbk'"

gbak -user -password

在InterBase数据库中默认的用户名是”sysdba”,默认的密码是”masterkey”后面的两个参数分别是要输入的地址,要注意的一点是,第二个参数要在盘符前面加上IP地址,如果是本地的话就是“127.0.0.1”,不加的话会报错。

在安装Firebird的时候会用到gsec命令,gsec是Firebird数据库的用户密码管理工具,要注意的是很有可能在Linux上会发生没有默认用户名密码的情况,如果这样的话就使用修改密码的口令从新修改密码就好了。下面附上程序的代码:

#encoding=utf-8

importos,sys,getopt

opts, args= getopt.getopt(sys.argv[1:], "hg:b:",["help","gbk=","gdb="])

input_file=""output_file=""

defusage():print """-h --help print the help

-g --gbk The path of the backup file

-b --gdb Have to backup the database path"""

for op, value inopts:if op in ("-g","--gbk"):

input_file=valueelif op in ("-b","--gdb"):

output_file=valueelif op in ("-h","--help"):

usage()

sys.exit()#input_file为要导入的备份文件地址#output_file为所要恢复的数据库地址#sysdba为InterBase数据库的默认账户名#masterkey为InterBase数据库的默认密码

defmain():ifos.path.isfile(input_file):

os.system('gbak -c -user "sysdba" -password "masterkey" "'+input_file+'" "127.0.0.1:'+output_file+'"')else:print 'Error: File does not exist'

if __name__ == '__main__':

main()

README FOR INTERBASE 5.6 Online documentation and Release Notes For a description of new features and changes in InterBase 5.6, use Acrobat Reader to view the ReleaseNotes.pdf file. In addition, the complete 5-volume document set for InterBase 5.5 is available in PDF format with InterBase 5.6. Use Adobe Acrobat Reader 3 to view these PDF files. To take advantage of the full-search indexing for the document set, you need Acrobat Reader 3.0.1 (or later) With Search. This version of Reader is included on your InterBase 5.6 CD-ROM. You can also download it from http://www.adobe.com/prodindex/acrobat/readstep.html If you go directly to this Adobe site, be sure to download the version "With Search", not the plain version. ACCESSING THE DOCUMENT SET: You can open any of the books directly from the InterBase folder in the Start menu if you have Acrobat Reader already installed and the PDF extension is associated with Acrobat Reader. To access the books from the Help menu in Server Manager, choose InterBase Help and choose the book you want from the "InterBase Books Online" section. ________________________ Uninstalling InterBase 5.6 The Windows InterBase installation allows you to choose between performing a complete install or selecting individual components. If you install a subset of the components, you can run the install again later to add more components. However, when you uninstall, only the components that you installed the last time are removed. ------------------------------------- Copyright (c) 1999 Inprise Corp. All rights reserved.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值