I started creating a plug-in to my application. It should install a webapplication into the local webspace. Like most webapplications this is based on PHP and MySQL.
The webapplication should use its own database user, so I need to get the credentials for the root user (user with global rights on the database) and use this informations to create the new database and a new user with password.
To solve this problem, I created a CustomPage where all these values must be filled by the user. I get all values back and pipe them into the following lines:
with $R0 = root usernamensExec::Exec '$INSTDIR\DB\MySQL4\bin\mysql -u $R0 -proot -e "CREATE DATABASE $R2"'
and $R2 = name of the database
As you can see in this line, -proot symbolises the parameter -p (switch for password entry) and a symbolic password root. And her I have my first problem:
If a user has no password set for his root user, neither the password nor the switch -p must be set. The CustomPage (custom.ini) is already prepared to serve a variable $R1 which could be placed as -p$R1, but mysql would react with an error if you trigger it with -p and provide no password. So I think the -p must be copied into $R0. How can I achieve this?
And another question. If the user enters a wrong password mysql will return an error. Can this error be used (or captured) to return e.g. a MessageBox and switch back to the CustomPage again...?
I hope somebody has a solution for me.
Chris