Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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';


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
Posted
Updated 27-Mar-16 19:12pm
v2
Comments
PIEBALDconsult 28-Mar-16 0:15am    
The commands you list don't make much sense. Are those the actual commands?
And I suspect you need to put quotes around the first one because of the SPACEs in it.
Kasthuri Gunabalasingam 28-Mar-16 0:29am    
yesh! Its actual commands!
First set the path- C:\Program Files\MySQL\MySQL Server 5.1\bin
then connect to sql server- MYSQL --user=root mysql
and finally create user name,and password- CREATE USER 'User89'@'localhost' IDENTIFIED BY 'aaa';

And this commands works properly in command line!
PIEBALDconsult 28-Mar-16 1:11am    
Just because it works on the command line doesn't mean it will work in a batch file.

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';"
 
Share this answer
 
v2
C:\Program Files\MySQL\MySQL Server 5.1\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

This one launch MYSQL if ypu are in right context.
SQL
CREATE USER 'User89'@'localhost' IDENTIFIED BY 'aaa';

This one is SQL commend and must be launch from inside the SQL server.

Solution 1 is probably what you want to do.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900