如何从PHPMyAdmin导出MySQL数据库并将其导入SQLite? [英] How do I export a MySQL database from PHPMyAdmin and import it to SQLite?

查看:217
本文介绍了如何从PHPMyAdmin导出MySQL数据库并将其导入SQLite?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从PHPMyAdmin(或MySQl Workbench)中导出数据库并将其导入到SQLite数据库中,这样我就可以进行本地编辑和测试而不会破坏实时版本.我对SQL非常陌生,因此所有导出选项等在这一点上对我来说都很密集.我尝试通过命令

I would like to export a database from PHPMyAdmin (or MySQl Workbench) and import it to a SQLite database so that I can do local editing and testing without screwing up the live version. I am very new to SQL, so all of the export options, etc, are rather dense to me at this point. I have tried using the default export settings PHPMyAdmin with the command

sqlite3 test_db.db < maindb.sql

以及

sqlite3--> .read maindb.sql

但是这些引发了很多语法错误和没有这样的表"错误.

But these throw a bunch of syntax errors and 'no such table' errors.

我还尝试了经常引用的脚本在此处找到的脚本,但是当我尝试时使用以下命令从MySQL Workbench导出运行此命令:

I have also tried the oft-cited script script found here, but when I try to run this using an export from MySQL Workbench, using the command:

943776/mysql2sqlite.sh maindb.sql | sqlite3 test_db.sqlite

我收到以下错误:

mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysql.sock' (2) when trying to connect

我没有正确配置导出吗?

Am I not configuring the exports correctly?

推荐答案

请参阅引用的脚本连接到数据库服务器本身.它确实期望转储!

Please see that the referenced script connects to the database server itself. It does not expect a dump!

./mysql2sqlite -h example.com -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite

这是应该执行脚本的方式.使用主机,用户名,密码和要转储的mysql数据库.

This is the way the script should be executed. With host, username, passwort and the mysql database you would like to dump.

由于不同的DBMS(例如MySQL和sqlite3)之间的数据库转储和DBMS功能可能存在很大差异,因此,我建议安装本地MySQL服务器,而不要使用sqlite3.对sqlite3进行更改时,您获得了什么优势?如果不进行更改,就无法将其应用于MySQL生产数据库?

Since database dumps and DBMS features can be severely different between different DBMS (like MySQL and sqlite3), I would recommend to install a local MySQL server instead of using sqlite3. What advantage have you achieved when you make changes to sqlite3, which you cannot apply to the MySQL production database without changes?

这篇关于如何从PHPMyAdmin导出MySQL数据库并将其导入SQLite?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆