Import mysql database through command lines - Advanced Installer Community
Halim
Posts: 2
Joined: Thu Dec 22, 2016 10:24 am

Import mysql database through command lines

I'm very new to Advanced Installer.
I tested to make an installer to install MySQL on Windows 8.1 using a non install Zip file.
I can initialize with my own ini file, install MySQL service,start the service and then create database using "Launch EXE with working directoy".
All steps worked successfully.
But I cannot import external exported sql file using "Launch EXE with working directoy" to work command line instructions which successfully work in command prompt.
Please let me know how can I accomplish to import my file.
I attach my AIP file to be able to check my project.

Thank you so much.
Attachments
myTest.aip
(186.83 KiB) Downloaded 631 times
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Import mysql database through command lines

Dear Halim,

Welcome to Advanced Installer forums.

I looked into your project but I couldn't find any "Launch EXE with working directoy" custom action that attempts an SQL file import so I can review its settings. Did you attach the correct project file?

A quick observation after looking into your project is that the "my.ini" file is imported in Windows Installer format. Since you don't change anything in the INI file dynamically at install time, I recommend you import it as a regular file instead. Windows Installer format is recommended when you need change something dynamically in the INI file during install, from user input in a dialog, etc.

Also, another observation for your other custom actions. Please keep in mind that you can reference files from the project (e.g. "my.ini", "test.sql") directly like this:

Code: Select all

[#my.ini]

Code: Select all

[#test.sql]
... instead of pre-fixing the [APPDIR] folder to the path. This is applicable for "my.ini" after you import it as a regular file.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Halim
Posts: 2
Joined: Thu Dec 22, 2016 10:24 am

Re: Import mysql database through command lines

Dear Mihai,
Thank you so much for your reply.
I'm sorry because i couldn't explain the actions in my project clearly.
I mean that
To run the command that initializes "my.ini" file,i added the custom action named "Launch EXE with working directory" ,in my project,I named "LaunchExeWithDirectory_initialize". (It worked successfully.)

To run the command that installs service,i added the custom action named "Launch EXE with working directory" ,in my project,I named "LaunchExeWithDirectory_installservice". (It worked successfully.)

To run the command that starts the MySQL service,i added the custom action named "Launch file" ,in my project,I named "LaunchFile_startservice". (It worked successfully.)

To run the command that creates the database,i added the custom action named "Launch EXE with working directory" ,in my project,i named "LaunchExeWithDirectory_createdb".(It worked successfully.)

Finally,to run the command that imports the MySQL database file,i added the custom action named "Launch file" ,in my project,I named "LaunchFile_importdb"
(It cannot import the database file.)

I made that commands run after "Finish Execution" stage by the Installation sequence.

I also thank for your recommendation to use "my.ini" file as a regular file but i used the INI file as windows installer format because i need to change the data_dir in [mysqld] section in "my.ini" file dynamically to create Data file under the directory user browses.

And I modified my project to make the file reference directly for "test.sql" as you suggested and also attach my AIP project again because it still doesn't work for importing mysql database.

Please let me know how can i do to accomplish this.

Thank you so much.
Attachments
mytest.aip
(187.49 KiB) Downloaded 602 times
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Import mysql database through command lines

Dear Halim,

The approach you took should work, but there are some cases when "Launch file" custom action can cause setbacks on running certain command lines. To debug in this direction we would need the installation log but it could very well lead to a dead end.

Instead I would recommend you to use "Launch EXE with working directory" like you did for the other working custom actions, or to use the "Launch file" custom action to launch a BAT file that executes your import commands.

Another best practice just came to mind while browsing your project. Prerequisite installation packages like MySQL Server should be added from the Prerequisites page. We also have some predefined prerequisites to get you started like MySQL Server 5.5.51.

Happy holidays!
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”