This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallAnywhere
- :
- InstallAnywhere Forum
- :
- Re: Run SQL Script
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 20, 2011
10:39 AM
Run SQL Script
Hi,
Hopefully this is a simple and quick query but I have been struggling to get this working for a while now. All I need to do is to get a command to run an SQL script against a MySQL database within InstallAnywhere 2011. The command is below:
C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql.exe --user=root --password=root < C:\createqb.sql
I know this is a valid command as it runs nicely using the actual command line.
Any response will be much appreciated.
Thanks in advance
AB
Hopefully this is a simple and quick query but I have been struggling to get this working for a while now. All I need to do is to get a command to run an SQL script against a MySQL database within InstallAnywhere 2011. The command is below:
C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql.exe --user=root --password=root < C:\createqb.sql
I know this is a valid command as it runs nicely using the actual command line.
Any response will be much appreciated.
Thanks in advance
AB
(8) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 20, 2011
12:56 PM
Don't know if it is the proper way or not, documentation is terrible for this product. And there is no way to debug it :confused:
But I had some luck doing the following:
(1) Use Modify text file to create a .bat file in the $USER_INSTALL_DIR$ say db.bat
The text in the bat file would be your command - don't forget to put quotes around it since the path has spaces:
Note: this would all be on one line:
"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql.exe" --user=root --password=root < C:\createqb.sql
(2) Execute Command with:
cmd /c $USER_INSTALL_DIR$\db.bat
(3) delete the bat file.
But I had some luck doing the following:
(1) Use Modify text file to create a .bat file in the $USER_INSTALL_DIR$ say db.bat
The text in the bat file would be your command - don't forget to put quotes around it since the path has spaces:
Note: this would all be on one line:
"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql.exe" --user=root --password=root < C:\createqb.sql
(2) Execute Command with:
cmd /c $USER_INSTALL_DIR$\db.bat
(3) delete the bat file.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 20, 2011
03:01 PM
Or you could use a ready made custom code: http://www.flexerasoftware.com/products/installanywhere/files-utilities.htm
Database Action: http://www.flexerasoftware.com/downloads/customcode/DataBaseCustomCode.zip
DatabaseAction
The custom code action connects to a database, reads SQL from a file, executes the queries, and closes the database.
Posted by: Flexera Software. Source included.
Database Action: http://www.flexerasoftware.com/downloads/customcode/DataBaseCustomCode.zip
DatabaseAction
The custom code action connects to a database, reads SQL from a file, executes the queries, and closes the database.
Posted by: Flexera Software. Source included.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 21, 2011
03:09 AM
Hi,
Thanks for the replies, I dont want to go down the custom code route and TomCarey, Ive tried your suggestion without success. Surely this should be a simple task. Anyone else?
Thanks again
Thanks for the replies, I dont want to go down the custom code route and TomCarey, Ive tried your suggestion without success. Surely this should be a simple task. Anyone else?
Thanks again
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 21, 2011
03:42 AM
I am not sure what and how exactly you would like to implement the execution of SQL script in your project.
How I would do is that first I will add the required database in Organization --> Hosts, then configure the database strings and finally in install phase add "Run SQL Script" action to run the required SQL file. That's all.
If you want I can post the sample project to you but I think you can do this by yourself if that is the requirement.
Does it answer your question?
-- Mac
How I would do is that first I will add the required database in Organization --> Hosts, then configure the database strings and finally in install phase add "Run SQL Script" action to run the required SQL file. That's all.
If you want I can post the sample project to you but I think you can do this by yourself if that is the requirement.
Does it answer your question?
-- Mac
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 21, 2011
03:48 AM
Thanks for your reply.
What makes it more complicated is that the mysql database server is installed as part of the installation script. I looked into your solution but as the database doesnt exist until the end of the install it obviously wont work.
What makes it more complicated is that the mysql database server is installed as part of the installation script. I looked into your solution but as the database doesnt exist until the end of the install it obviously wont work.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 21, 2011
06:28 AM
In this case maybe you need to run your script in post-install (I've developed a similar setup).
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 21, 2011
07:16 AM
Ive tried adding the action to post install and that doesnt work either.
pv7721 please enlighten me into how you got it to work.
Thanks in advance
pv7721 please enlighten me into how you got it to work.
Thanks in advance
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 21, 2011
11:11 AM
It might not be easy to debug what happens in your case: it depends both on your setup and your SQL script. You install MySQL all right, but does your setup launch it as well? Have you added something to check the connection?