【问题标题】:MYSQL database transfer using knexMYSQL数据库传输使用knex
【发布时间】:2017-11-15 07:11:52
【问题描述】:
const exec_string = 'mysqldump --user=abc--password=abc--host=localhost test | mysql --user=xyz--password=xyz --host=localhost new_test';
knex.raw(exec_string)
.then((res) => {
    console.log("res >>",res);
})
.catch((err)=>{
    console.log("err >>",err);
})

这里我有测试数据库。我想使用 knex npm 在 new_test 数据库中传输该数据库。 如果有其他解决方案,请建议我。

【问题讨论】:

    标签: mysql node.js knex.js


    【解决方案1】:

    Knex 不是用于此目的的正确工具。使用 exec 或 shelljs 听起来是个不错的方法。

    【讨论】:

    • const exec_string = 'cd C:/xampp/mysql/bin mysqldump --user=abc--password=abc--host=localhost test | cd C:/xampp/mysql/bin mysql --user=abc--password=abc--host=localhost new_test'; exec(exec_string, function(error, stdout, stderr) {}); 当我执行这段代码时遇到这个错误系统找不到指定的路径。 cd C:/xampp/mysql/bin 路径可以成功运行在 cmd 中。@Mikael Lepistö
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-15
    相关资源
    最近更新 更多