导入导出数据库及其数据

命令行导出数据库: 
1,进入MySQL目录下的bin文件夹:cd MySQL中到bin文件夹的目录 
如我输入的命令行:cd C:\Program Files\MySQL\MySQL Server 4.1\bin 

(如果你配置了mysql的环境变量就直接在在dos下进行下面内容)
2,导出数据库:mysqldump -u 用户名 -p 数据库名 > 导出的文件名 
如我输入的命令行:mysqldump -u root -p news > news.sql   (输入后会让你输入进入MySQL的密码) 
(如果导出单张表的话在数据库名后面输入表名即可) 

 

如果运行出现这个错误

mysqldump: Got error: 23: Out of resources when opening file './discuz/ecs_user_
address.MYD' (Errcode: 24) when using LOCK TABLES

 

 

解决办法:加上-skip-lock-tables选项即可。

例:
mysqldump -uxxx -pxxx --database ddd --skip-lock-tables > new.sql

 

后面的文件  如果你直接写文件名   会生成在mysql的bin目录下    你也可以自己其它URL


命令行导入数据库: 
1,将要导入的.sql文件移至bin文件下,这样的路径比较方便 
2,同上面导出的第1步 
3,进入MySQL:mysql -u 用户名 -p 
如我输入的命令行:mysql -u root -p   (输入同样后会让你输入ySQL的密码) 
4,在MySQL-Front中新建你要建的数据库,这时是空数据库,如新建一个名为news的目标数据库 
5,输入:mysql>use 目标数据库名 
如我输入的命令行:mysql>use news; 
6,导入文件:mysql>source 导入的文件名; 
如我输入的命令行:mysql>source news.sql;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
# $language = "VBScript" # $interface = "1.0" '作者;小怪兽怪瘦 Sub Main Const ForReading = 1, ForWriting = 2, ForAppending = 8 Dim fso,file1,line,str1,params Set fso = CreateObject("Scripting.FileSystemObject") Set file1 = fso.OpenTextFile("D:\backup\list.txt",Forreading, False) crt.window.show 3 crt.Screen.Synchronous = True do while file1.AtEndOfStream True '读取每一行 line = file1.ReadLine '分割IP,用户名,密码 特权密码 型号简写(z m h b) 位置 params = Split (line) ip = params(0) user = params(1) password = params(2) su = params(3) mode = params(4) whereis = params(5) crt.session.LogFileName = "D:\backup\log\"&ip&"_"&whereis&"_20190620.txt" '提供日志,修改后面日期即可 crt.session.Log(true) crt.Session.Connect ( "/SSH2 /L "&user&" /PASSWORD "&password&" "&ip) '建立SSH连接 if mode = "m" then 'm 代迈普型号 crt.Screen.Send "enable" & chr(13) crt.Screen.WaitForString "assword:" crt.Screen.Send params(3) & chr(13) crt.Screen.WaitForString "#" '关闭more提示 crt.Screen.Send "more off" & chr(13) crt.Screen.WaitForString "#" '执行命令集 Set cmdfile = fso.OpenTextFile("D:\backup\cmd-mp.txt",Forreading, False) do while cmdfile.AtEndOfStream True line2 = cmdfile.ReadLine crt.Screen.Send line2 & Chr(13) crt.Screen.waitForString "#" loop crt.Screen.Send "show running-config" & chr(13) crt.Screen.WaitForString "#" '打开more提示 crt.Screen.Send "more on" & chr(13) crt.Screen.WaitForString "#" crt.Screen.Send "exit" & chr(13) crt.Screen.WaitForString ">" crt.Session.Disconnect end if if mode = "c" then 'c 代思科型号 crt.Screen.WaitForString ">" crt.Screen.Send "enable" & chr(13) crt.Screen.WaitForString "assword:" crt.Screen.Send params(3) & chr(13) crt.Screen.WaitForString "#" '关闭more提示 crt.Screen.Send "configure terminal" & chr(13) crt.Screen.WaitForString "config)#" crt.Screen.Send "line vty 0 4" & chr(13) crt.Screen.WaitForString "line)#" crt.Screen.Send "length 0" & chr(13) crt.Screen.WaitForString "line)#" crt.Screen.Send "end" & chr(13) crt.Screen.WaitForString "#" '执行命令集 Set cmdfile = fso.OpenTextFile("D:\backup\cmd-cisco.txt",Forreading, False) do while cmdfile.AtEndOfStream True line2 = cmdfile.ReadLine crt.Screen.Send line2 & Chr(13) crt.Screen.waitForString "#" loop crt.Screen.Send "show running-config" & chr(13) crt.Screen.WaitForString "#" '打开more提示 crt.Screen.Send "configure terminal" & chr(13) crt.Screen.WaitForString "config)#" crt.Screen.Send "line vty 0 4" & chr(13) crt.Screen.WaitForString "line)#" crt.Screen.Send "no length" & chr(13) crt.Screen.WaitForString "line)#" crt.Screen.Send "end" & chr(13) crt.Screen.WaitForString "#" crt.Session.Disconnect end if if mode = "r" then 'r 代锐捷型号 crt.Screen.WaitForString ">" crt.Screen.Send "enable" & chr(13) crt.Screen.WaitForString "assword:" crt.Screen.Send params(3) & chr(13) crt.Screen.WaitForString "#" '关闭more提示 crt.Screen.Send "configure terminal" & chr(13) crt.Screen.WaitForString "config)#" crt.Screen.Send "line vty 0 15" & chr(13) crt.Screen.WaitForString "line)#" crt.Screen.Send "length 0" & chr(13) crt.Screen.WaitForString "line)#" crt.Screen.Send "end" & chr(13) crt.Screen.WaitForString "#" '执行命令集 Set cmdfile = fso.OpenTextFile("D:\backup\cmd-rj.txt",Forreading, False) do while cmdfile.AtEndOfStream True line2 = cmdfile.ReadLine crt.Screen.Send line2 & Chr(13) crt.Screen.waitForString "#" loop crt.Screen.Send "show running-config" & chr(13) crt.Screen.WaitForString "#" '打开more提示 crt.Screen.Send "configure terminal" & chr(13) crt.Screen.WaitForString "config)#" crt.Screen.Send "line vty 0 15" & chr(13) crt.Screen.WaitForString "line)#" crt.Screen.Send "no length" & chr(13) crt.Screen.WaitForString "line)#" crt.Screen.Send "end" & chr(13) crt.Screen.WaitForString "#" crt.Session.Disconnect end if if mode = "z" then 'z 代中兴型号 crt.Screen.Send "enable" & chr(13) crt.Screen.WaitForString "assword:" crt.Screen.Send params(3) & chr(13) crt.Screen.WaitForString "#" '执行命令集 Set cmdfile = fso.OpenTextFile("D:\backup\cmd-zx.txt",Forreading, False) do while cmdfile.AtEndOfStream True line2 = cmdfile.ReadLine crt.Screen.Send line2 & Chr(13) if (crt.Screen.WaitForString (" --More--",1)False) then crt.Screen.Send " " & chr(13) else crt.Screen.Send chr(13) end if crt.Screen.waitForString "#" loop 'crt.Screen.Send "show running-config" & chr(13) 'crt.Screen.WaitForString " --More--" 'crt.Screen.WaitForString "#" crt.Session.Disconnect
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值