diff --git a/bucket/mysql.json b/bucket/mysql.json index efafa0b2d3..4920056ff0 100644 --- a/bucket/mysql.json +++ b/bucket/mysql.json @@ -39,23 +39,35 @@ "bin/perror.exe", "bin/zlib_decompress.exe" ], - "persist": "data", - "post_install": [ - "if (!(Test-Path \"$dir/my.ini\")) {", + "persist": [ + "data", + "my.ini" + ], + "pre_install": [ + "$ini = \"$dir\\my.ini\"", + "if (!(Test-Path \"$ini\")) {", " # Using $dir instead of $persist_dir, causes this error:", - " # [ERROR] [MY-010187] [Server] Could not open file 'C:/Users/ex/scoop/apps/mysql/current/data/host.err' for error logging: Permission denied", - " $dir_u = ($persist_dir -replace '\\\\', '/')", - " Add-Content \"$dir/my.ini\" '[mysqld]' -Encoding Ascii", - " Add-Content \"$dir/my.ini\" \"datadir=$dir_u/data\" -Encoding Ascii", + " # [ERROR] [MY-010187] [Server] Could not open file '~/scoop/apps/mysql/current/data/host.err' for error logging: Permission denied", + " Add-Content -Path \"$ini\" -Value \"[mysqld]`ndatadir=$($persist_dir -replace '\\\\', '/')/data\" -Encoding Ascii", " # Set username so it's not required when connecting", - " Add-Content \"$dir/my.ini\" '[client]' -Encoding Ascii", - " Add-Content \"$dir/my.ini\" 'user=root' -Encoding Ascii", - "}", - "if (!(Test-Path \"$dir/data\\auto.cnf\")) {", - " # Initialize data directory (without generating root password)", - " mysqld.exe --initialize-insecure", + " Add-Content -Path \"$ini\" -Value \"[client]`nuser=root\" -Encoding Ascii", "}" ], + "post_install": [ + "if (!(Test-Path \"$dir\\data\\auto.cnf\")) {", + " warn 'Initializing data directory ...'", + " Invoke-ExternalCommand -FilePath \"$dir\\bin\\mysqld.exe\" -ArgumentList '--initialize-insecure'", + " warn 'Database has been initialized (username: root, password: )'", + "}" + ], + "notes": [ + "Run 'mysqld --standalone' or 'mysqld --console' to start the Database,", + "or run following command as administrator to register MySQL as a service. See: https://dev.mysql.com/doc/refman/en/windows-start-service.html", + "", + "mysqld --install MySQL --defaults-file=\"$dir\\my.ini\"", + "", + "To stop and/or delete the Service run 'sc stop MySQL' and 'sc delete MySQL'." + ], "checkver": { "url": "https://dev.mysql.com/downloads/mysql/", "re": "

MySQL Community Server ([\\d.]+)"