SQLserver数据库导出的sql文件如何导入MySQL
<h4>文章目录</h4><ul class=" list-paddingleft-2"><li>1、准备好要使用的文件和工具</li><ul class=" list-paddingleft-2" style="list-style-type: square;"><li>下载链接</li><li>1.1、目标数据库---Mysql。</li><li>1.2、源数据库---SQLserver</li><li>1.3、工具:SQLyog (需要旗舰版/企业版/终极版),这里给大家推荐我使用的</li></ul><li>2、安装SQLyog</li><li>3、运行SQLyog</li><li>3、开始导入数据</li><ul class=" list-paddingleft-2" style="list-style-type: square;"><li>3.1、打开SQLyog外部数据导入向导</li><li>3.2、进入SQLyog外部数据导入向导</li><li>3.3、选择数据源</li><li>3.4、ODBC System DSN 警告</li><li>3.5、创建新数据源</li><li>3.6、选择安装数据源的驱动</li><li>3.7、 选择数据源的名称和存放路径</li><li>3.8、建立用于连接SQL Server的ODBC数据源</li><li>3.9、选择验证源数据库的方式</li><li>3.10、选择更改默认的数据库</li><li>3.11、选择数据源</li><li>3.12、选择想要导出的数据库</li><li>3.13、指定表副本或者查询</li><li>3.14、选择表</li><li>3.15、错误处理</li><li>3.16、想要何时运行任务</li><li>3.17、报错信息处理</li><li>3.18、正在完成数据导入向导</li><li>3.19、向导完成</li><li>3.20、验证数据的导入情况</li></ul></ul><h3>1、准备好要使用的文件和工具</h3><h4>1.1、目标数据库—Mysql。</h4><h4>1.2、源数据库—SQLserver</h4><h4>1.3、工具:SQLyog (需要旗舰版/企业版/终极版),这里给大家推荐我使用的</h4><h5>下载链接:</h5><h5>https://pan.baidu.com/s/1TlLiRI9stxqTc-wBJ5p6UA 提取码:<span style="color:#dd0000">v6d5</span></h5><h3>2、安装SQLyog</h3><p>工具很小,自定义安装目录。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-23110114503Oa.png"/></p><h3>3、运行SQLyog</h3><p>打开软件后,依次点击:文件---->新连接。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-23110114503H46.png"/><br/> <span style="color:#dd00dd">在建立连接的界面上,输入要连接的mysql数据库的信息:</span><br/> <span style="color:#dd0000">保/存的连接:<span style="color:#00dd00">连接的描述</span><br/> <span style="color:#dd0000">MySQL Host Address :</span><span style="color:#00dd00">mysql数据库所在机器的IP地址。</span><br/> <span style="color:#dd0000">用户名:</span><span style="color:#00dd00">mysql。因为mysql不同用户有不同的登录方式,所以用户名要写自己的可以远程管理mysql的用户。</span><br/> <span style="color:#dd0000">密码:</span></span><span style="color:#00dd00">远程管理用户的密码。MySQL同一用户可以设置多个不同登录方式的密码,这里要写允许远程管理的密码。</span><br/> <span style="color:#dd0000">端口:</span><span style="color:#00dd00">默认是3306,根据情况写自己的。</span><br/> 最好先测试连接,测试成功后再连接。<br/> <br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-23110114503K58.png"/><br/> 测试成功,点击连接。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-23110114503O34.png"/><br/> 连接成功后,先在自己的mysql里建立自己要导入数据的空数据库(数据库的名字和sqlserver里面的要一样)。<br/> 我这里建立了多个要导入数据的目标数据库,用其中的jbpm库来演示。</p><h3>3、开始导入数据</h3><h4>3.1、打开SQLyog外部数据导入向导</h4><p>按下图所示,依次点击:数据库—>导入---->导入外部数据。或者直接点击导入外部数据的快捷按钮。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-23110114503O06.png"/></p><h4>3.2、进入SQLyog外部数据导入向导</h4><p>选中开始新工作,点击下一页。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-23110114503R06.png"/></p><h4>3.3、选择数据源</h4><p>数据源类型选择:任何ODBC数据源。<br/> 建立新的DSN。DSN就是数据导入任务。<br/> 输入数据源凭证:就是sqlserver数据库的用户名(sa)和密码。<br/> 然后点击下一步。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-23110114503W21.png"/></p><h4>3.4、ODBC System DSN 警告</h4><p>选择“确认”,跳过此警告。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-23110114503W57.png"/></p><h4>3.5、创建新数据源</h4><p>数据源类型:文件数据源。点击下一步。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-23110114503Q35.png"/></p><h4>3.6、选择安装数据源的驱动</h4><p>这里选择:SQL Server。然后点击下一页。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-23110114503Q61.png"/></p><h4>3.7、 选择数据源的名称和存放路径</h4><p>这里的数据源名称和存放路径都是自己定义的,点击浏览。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-23110114503S14.png"/><br/> 选择一个存放数据源的路径<br/> 其实存放是DSN任务。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145039303.png"/><br/> 在自己指定的文件夹里新建一个jbpm.txt文档(以数据库的名字命名,方便以后查找)。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145039544.png"/><br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145039304.png"/><br/> 修改扩展名,将jbpm.txt修改成jbpm.dsn。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145039120.png"/><br/> 选中jbpm.dsn文件,点击保存。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-2311011450391Q.png"/><br/> 确认好路径后,点击下一页。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-2311011450403N.png"/><br/> 确认信息后,点击完成。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145040527.png"/></p><h4>3.8、建立用于连接SQL Server的ODBC数据源</h4><p>描述可以不用填写,服务器填写SQLserver数据库的ip地址。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145040945.png"/></p><h4>3.9、选择验证源数据库的方式</h4><p>选择:使用用户输入登录ID和密码的SQL Server验证。<br/> 输入:SQL Server数据库的用户名(sa)和密码。然后点击下一页。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145040422.png"/></p><h4>3.10、选择更改默认的数据库</h4><p>这里选则jbpm数据库(根据自己的任务选择自己要导入数据的数据库)。然后点击下一页。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145040N1.png"/><br/> 这里默认选择字符数据翻译,点击完成。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145040639.png"/><br/> 继续选择确认。<br/> 可以跳过测试数据源。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145041562.png"/><br/> 自动重新进入向导页面,选择覆盖数据源文件。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145041344.png"/></p><h4>3.11、选择数据源</h4><p>选择刚才建好的jbpm.dsn文件,输入SQLserver的用户名(sa)和密码。点击下一页。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145041G9.png"/><br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145041932.png"/></p><h4>3.12、选择想要导出的数据库</h4><p>这里我们选择jbpm。<em>我们开始定义好以jbpm库做演示</em>。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145041100.png"/><br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-2311011450415c.png"/></p><h4>3.13、指定表副本或者查询</h4><p>从数据源拷贝表,继续点击下一页。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145042932.png"/></p><h4>3.14、选择表</h4><p>点击source前面的方格,选中所有的表格。闪烁时间较长,耐心等待。<br/> 注:只有SQLyog的企业版/旗舰版/终极版才支持选择所有的表,其他版本只能选2个表。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145042Y3.png"/><br/> 全选之后,点击下一页。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-2311011450423Z.png"/></p><h4>3.15、错误处理</h4><p>这里可以不用选,直接点击下一页。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145042G5.png"/></p><h4>3.16、想要何时运行任务</h4><p>这里我么选择立刻运行,点击下一页。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145042D3.png"/></p><h4>3.17、报错信息处理</h4><p>一般外部数据库导入都会有报错处理,毕竟是两个不同的数据库软件。<br/> 我的的报错信息是:<br/> 导入数据库的字符集和mysql数据库的字符集不一致;<br/> 处理办法:修改mysql数据库jbpm库的字符集。<br/></p><pre data-index="0" class="set-code-show prettyprint">mysql> use jbpmDatabase changed
mysql> alter database jbpm character set utf8mb3;Query OK, 1 row affected, 1 warning (0.01 sec)1234</pre><p><img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145043K4.png"/><br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145043M4.png"/><br/> 处理好mysql数据库的jbpm库的字符集后,在向导中点击上一步,重新运行一下任务。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145043161.png"/><br/> 重新运行任务。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-2311011450435Y.png"/></p><h4>3.18、正在完成数据导入向导</h4><p>这里我们看到数据库开始导入了,需要等待一段时间。显示完成(成功)后点击下一页,没有完成前下一页按钮是灰色的。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-2311011450432I.png"/></p><h4>3.19、向导完成</h4><p>最后点击完成。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145043107.png"/></p><h4>3.20、验证数据的导入情况</h4><p>在SQLyog中验证导入的数据。断开连接再重新连接,或者点击刷新按钮就会看到jbpm数据库导入的表了。<br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145044450.png"/><br/> <img style="max-width:100%!important;height:auto!important;" src="https://zhuji.jb51.net/uploads/allimg/20231101/1-231101145044a6.png"/></p>
頁:
[1]