File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Pass parameters to a mysql sql file from a batch file in windows
Joined: Jul 08, 2007
Aug 27, 2013 14:06:41
I have two files, create_user.bat and create_user.sql This is the content of create_user.bat :
cls mysql -uroot -proot -e "set @P_USER:='AAAAA'; set @HOST='localhost'; set @P_PW='BBBB'; set @DBNAME:='TEMPDB'; source create_generic.sql;" :END
This is the content of the .sql file :
CREATE USER '@P_USER'@'@HOST' IDENTIFIED BY '@P_PW'; CREATE DATABASE IF NOT EXISTS '@DBNAME'; GRANT ALL PRIVILEGES ON *.* TO '@P_USER'@'@HOST' IDENTIFIED BY '@P_PW' WITH GRANT OPTION;
Upon running the bat file, first it gave me this error :
ERROR 1105 (HY000) at line 16 in file: 'create_user.sql': Malformed hostname (illegal symbol: '@')
Then I changed this '@P_USER'@'@HOST' to '@P_USER'@'localhost' then I get this error :
ERROR 1396 (HY000) at line 16 in file: 'create_user.sql': Operation CREATE USER failed for '@P_USER'@'localhost'
I have read similar questions on various forums and I think am following everything. I dont see where I am going wrong. How do I go about fixing this script please?
I agree. Here's the link:
subject: Pass parameters to a mysql sql file from a batch file in windows
Unable to drop user in mysql
Tomcat Connection pool creating too many connections, stuck in sleep mode
mysql JDBC driver classpath problem.
Problem with Connecting to mysql using java
Help - - - ClassNotFoundException: com.mysql.jdbc.Driver
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014