phpmyadmin 导出mysql,如何从PHPMyAdmin导出MySQL数据库并将其导入SQLite?

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

as well as

sqlite3--> .read maindb.sql

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

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

I get the following error:

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

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

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?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值