diff --git a/deploy/windows/installer/shopdb-install.ps1 b/deploy/windows/installer/shopdb-install.ps1 index 5f2b759..678fecf 100644 --- a/deploy/windows/installer/shopdb-install.ps1 +++ b/deploy/windows/installer/shopdb-install.ps1 @@ -786,8 +786,23 @@ data, STOP: you are about to destroy a database. CREATE DATABASE IF NOT EXISTS $DbName CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER IF NOT EXISTS '$DbUser'@'localhost' IDENTIFIED BY '$appPass'; CREATE USER IF NOT EXISTS '$DbUser'@'127.0.0.1' IDENTIFIED BY '$appPass'; +-- ::1 as well. On current Windows 'localhost' resolves to the IPv6 loopback +-- FIRST, so an operator who types localhost instead of 127.0.0.1 arrives as +-- '$DbUser'@'::1' - an account that did not exist, and MySQL answers "Access +-- denied" naming a host the operator never typed. +CREATE USER IF NOT EXISTS '$DbUser'@'::1' IDENTIFIED BY '$appPass'; +-- ALTER after CREATE, because CREATE USER IF NOT EXISTS is a NO-OP on an +-- existing user and does NOT change its password. This stage generates a fresh +-- password every run and overwrites .dbpass with it, so on any re-run after a +-- partial failure the file held a password the server had never been told - +-- "Access denied" while the operator was looking straight at the right file. +-- ALTER makes the stored password and the handoff agree, every time. +ALTER USER '$DbUser'@'localhost' IDENTIFIED BY '$appPass'; +ALTER USER '$DbUser'@'127.0.0.1' IDENTIFIED BY '$appPass'; +ALTER USER '$DbUser'@'::1' IDENTIFIED BY '$appPass'; GRANT ALL PRIVILEGES ON $DbName.* TO '$DbUser'@'localhost'; GRANT ALL PRIVILEGES ON $DbName.* TO '$DbUser'@'127.0.0.1'; +GRANT ALL PRIVILEGES ON $DbName.* TO '$DbUser'@'::1'; ALTER USER 'root'@'localhost' IDENTIFIED BY '$rootPass'; FLUSH PRIVILEGES; "@