Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Root user password assignment in MySQL and MariaDB #1345

Merged
merged 2 commits into from
Jul 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/modules/services/mysql.nix
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ with lib; let
${concatMapStrings (user: ''
echo "Adding user: ${user.name}"
${optionalString (user.password != null) "password='${user.password}'"}
( echo "CREATE USER IF NOT EXISTS '${user.name}'@'localhost' ${optionalString (user.password != null) "IDENTIFIED BY '$password'"};"
(
if [ "${user.name}" = "root" ] && [ -n ${user.password} ]; then
echo "ALTER USER 'root'@'localhost' IDENTIFIED BY '$password';"
else
echo "CREATE USER IF NOT EXISTS '${user.name}'@'localhost' ${optionalString (user.password != null) "IDENTIFIED BY '$password'"};"
fi
${concatStringsSep "\n" (mapAttrsToList (database: permission: ''
echo 'GRANT ${permission} ON ${database} TO `${user.name}`@`localhost`;'
'')
Expand Down
Loading