是否可以从Windows命令行执行数据库插入? [英] Is it possible to execute a database insert from the Windows command-line?

查看:216
本文介绍了是否可以从Windows命令行执行数据库插入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,如果你想执行一个MySQL命令,你只需打开MySQL命令行,但是我试图通过Windows命令行执行命令。

Normally if you wanted to execute a MySQL command you would just open up the MySQL command-line, but I'm trying to execute the command via Windows command-line.

这可能是不可能的,但我想象的代码看起来像这样:

It's possible that this is not possible, but I imagined the code looking something like this:

mysql -u root -pInsertPassword; USE InsertDatabaseName; INSERT INTO InsertDatabaseName (col1, col2) VALUES('data1', 'data2' ) 

系统设置:


  • MySQL: 5.1.53-社区MySQL社区服务器(GPL)

  • 窗口 7

  • MySQL: 5.1.53-community MySQL Community Server (GPL)
  • Window: 7

推荐答案

Windows支持管道,因此您可以执行以下操作:

Windows supports pipes, so you can do:

echo insert into ... | mysql -uroot -p databaseName

这篇关于是否可以从Windows命令行执行数据库插入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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