批处理文件仅运行第一个命令 [英] Batch files run only first command
问题描述
我创建了一个sqlex.bat文件,它包含一组cmd命令,
I have created a sqlex.bat file , it contains set of cmd commands,
C:\Program Files\MySQL\MySQL Server 5.1\bin
MYSQL --user=root mysql
CREATE USER 'User89'@'localhost' IDENTIFIED BY 'aaa';
当我运行这个sqlex.bat文件时,它只执行第一行!
如何解决这个问题。 。?
我尝试了什么:
我把CALL 在所有命令之前,也没有摧毁
when I run this sqlex.bat file, it executes first line only!
How can I resolve this..?
What I have tried:
I put "CALL" in before all commands, that also not wroking
推荐答案
尝试(所有一行):
Try (all one line):
c:\> "C:\Program Files\MySQL\MySQL Server 5.1\bin\MYSQL" --user=root -e "CREATE USER 'User89'@'localhost' IDENTIFIED BY 'aaa';"
C:\Program Files\MySQL\MySQL Server 5.1\bin
如果 bin
不是可执行文件,则该行不执行任何操作。但是
this line does nothing if bin
is not an executable. But
CD "C:\Program Files\MySQL\MySQL Server 5.1\bin"
会有意义。
would make sense.
MYSQL --user=root mysql
这一次启动MYSQL如果是ypu在正确的上下文中。
This one launch MYSQL if ypu are in right context.
CREATE USER 'User89'@'localhost' IDENTIFIED BY 'aaa';
这是SQL推荐,必须从SQL服务器内部启动。
解决方案1可能就是你想要做的。
This one is SQL commend and must be launch from inside the SQL server.
Solution 1 is probably what you want to do.
这篇关于批处理文件仅运行第一个命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!