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 handling of mysql passwords with weird characters in it #2660

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

eldering
Copy link
Member

The password is passed inside the environment variable DATABASE_URL which is URI-like. However, it must be URL encoded there if it contains any strange characters, like a space, %, etc.

Also add a handy command dj_setup_database update-password that reset the MySQL database user password to what it currently in etc/dbpassword.secret, and handle weird passwords in this script. This script is now bash, and should probably be rewritten in PHP or so.

@eldering eldering force-pushed the fix-mysql-password branch 2 times, most recently from 169aa03 to ba630f7 Compare August 25, 2024 17:22
sql/dj_setup_database.in Outdated Show resolved Hide resolved
See for reference:
- https://dev.mysql.com/doc/refman/8.0/en/connecting-using-uri-or-key-value-pairs.html#connecting-using-uri
- https://symfony.com/doc/current/doctrine.html
but note that we must use `rawurlencode` instead of `urlencode` which
differ in how they encode a space (as tested).

Fixes: #2651
Closes: #2502 as this is likely fixed but I couldn't reproduce it
There was no easy way to do this, besides also completely
dropping and recreating an empty database.
Use URL encoding in DATABASE_URL and return mysql_options
as an array (via ugly global variable), so each element
in it can be separately added to the command line using
`@` for expansion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants