我的应用程序使用MySQL服务器。在inno安装脚本中详细说明了以下操作:
代码中的()
运行中的
该脚本运行良好,但是我希望运行部分的项目1和2也在代码中执行,因此:
代码中的()
运行中的
但第二种方案是在包含新用户和密码以及创建数据库时出错。在运行过程中,不会发生这种情况。
我在代码中用于插入用户和密码的代码如下:
if (CurStep = ssInstall) then
begin WizardForm.ProgressGauge.Style: = npbstMarquee; WizardForm.StatusLabel.Caption: = 'Starting service MySQL on Windows. This may take a few minutes ... ';
if not Exec (ExpandConstant ('{pf} \ MySQL \ MySQL Server 5.5 \ bin \ mysqld.exe'), 'mysql-u root GRANT ALL PRIVILEGES ON *. * TO myusername @ localhost IDENTIFIED BY mypassword WITH GRANT OPTION;' '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then
MsgBox ('The MySQL service failed. Code:' + IntToStr (ResultCode) mbInformation, MB_OK);
WizardForm.ProgressGauge.Style: = npbstNormal; WizardForm.StatusLabel.Caption: ='';
end;发布于 2013-05-27 20:49:30
MySQL客户端mysql.exe使用param -e接收SQL命令。
命令应该如下所示
mysql -uroot -e"GRANT ALL PRIVILEGES ON *.* TO 'myusername'@'localhost' IDENTIFIED BY 'mypassword' WITH GRANT OPTION"还不要忘记设置根密码。
https://stackoverflow.com/questions/16779810
复制相似问题