如何创建运行MySQL命令行的脚本?

时间:2022-08-10 01:10:27

I'm trying to import about 20 .csv files into MySQL and I'm fed up with doing it via phpmyadmin's import gui.

我正在尝试将大约20个.csv文件导入MySQL,我厌倦了通过phpmyadmin的import gui进行操作。

Is there a way to do this by batch without typing on the command line? i.e. a script that will run when double clicked (Windows). What I want is:

有没有办法在批处理的情况下批量执行此操作而不在命令行上输入?即双击时运行的脚本(Windows)。我想要的是:

  1. I have files like porsche.csv, ferrari.csv etc
  2. 我有像porsche.csv,ferrari.csv等文件

  3. I want to import each of these into tables with the same name (i.e. porsche, ferrari)
  4. 我想将这些中的每一个导入到同名的表中(即保时捷,法拉利)

  5. Empty the table before importing the text file (using delete flag). How does it handle new fields?
  6. 在导入文本文件之前清空表(使用删除标志)。它如何处理新字段?

  7. Ignore first line (header).
  8. 忽略第一行(标题)。

From what I've gathered so far: we use mysqlimport: http://dev.mysql.com/doc/refman/5.0/en/mysqlimport.html

从我到目前为止收集到的内容:我们使用mysqlimport:http://dev.mysql.com/doc/refman/5.0/en/mysqlimport.html

I'll try to fiddle around with the options and see if I can get something working.

我会尝试摆弄各种选项,看看能不能搞定。

1 个解决方案

#1


0  

On Windows, the easiest way is to use a batch script.

在Windows上,最简单的方法是使用批处理脚本。

Read the documentation on available options.

阅读有关可用选项的文档。

The batch script would look something like:

批处理脚本看起来像:

@echo off
cd C:\Program Files\MySQL\MySQL Workbench 5.2 CE\

mysqlimport ...

Other related questions:

其他相关问题:

#1


0  

On Windows, the easiest way is to use a batch script.

在Windows上,最简单的方法是使用批处理脚本。

Read the documentation on available options.

阅读有关可用选项的文档。

The batch script would look something like:

批处理脚本看起来像:

@echo off
cd C:\Program Files\MySQL\MySQL Workbench 5.2 CE\

mysqlimport ...

Other related questions:

其他相关问题: