In linux I can do something like this:
在linux中,我可以这样做:
mysql -u user -p=pass somedb <(echo "create database foo;")
How can I do that with windows batch scripts?
如何使用Windows批处理脚本执行此操作?
Basically, I want to make a batch file that runs a sql script without having to keep the script in a separate file.
基本上,我想制作一个运行sql脚本的批处理文件,而不必将脚本保存在单独的文件中。
Thanks
2 个解决方案
#1
0
One way is to echo the SQL commands into a file, run the mysql command with option to include the SQL file, and then remove the file (if you really don't want it.)
一种方法是将SQL命令回显到一个文件中,运行带有选项的mysql命令以包含SQL文件,然后删除该文件(如果你真的不想要它。)
#2
0
You can do
你可以做
echo create database foo;|mysql ...
just fine, but for multiple lines you really want to make a temporary file you just pass to MySQL to read.
很好,但对于多行,你真的想制作一个临时文件,你只需要传递给MySQL阅读。
#1
0
One way is to echo the SQL commands into a file, run the mysql command with option to include the SQL file, and then remove the file (if you really don't want it.)
一种方法是将SQL命令回显到一个文件中,运行带有选项的mysql命令以包含SQL文件,然后删除该文件(如果你真的不想要它。)
#2
0
You can do
你可以做
echo create database foo;|mysql ...
just fine, but for multiple lines you really want to make a temporary file you just pass to MySQL to read.
很好,但对于多行,你真的想制作一个临时文件,你只需要传递给MySQL阅读。