如何从MySQL中的.bat文件导入数据? [英] How do I import data from a .bat file in MySQL?

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

问题描述

我创建了一个.bat文件(import_file.bat):

I created a .bat file (import_file.bat):

set database_name=nome_db
mysql –u root --password=pass --database %database_name% < c:/import_geco/sql_svuta.sql
mysql –u root --password=pass --database %database_name% < c:/import_geco/carica_dati.sql

在命令行中,在我进入MySQL的bin目录:

From the command line, in the MySQL bin directory I entered:

mysql/bin>c:/import_db/import_file.bat

...但它不工作,而是返回MySQL的帮助信息。

... but it doesn't work, instead it returns MySQL help info.

如果我创建一个.bat文件导出表(export.bat):

If I create a .bat file to export table (export.bat):

mysqldump --no-create-info -u root nome_db nome_tabella  > c:/backup_db/export.sql

...并在命令行中输入:

... and enter at the command line:

mysql/bin>c:/import_db/export.bat

它的工作原理。

推荐答案

您获得的帮助文件,因为你有一个畸形的命令。您正试图管的东西到命令行。您可能需要使用 -e (--execute)命令,您可以管文件或使用 LOAD DATA文件

You get the help file because you have a malformed command. You are attempting to pipe something to the command line. YOu probably need to use the -e (--execute) command, and you can either pipe the file or use LOAD DATA FILE

请参阅: HTTP://dev.mysql。 COM / DOC / refman / 5.5 / EN / MySQL的命令,options.html

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

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