A very good solution is to use a connection service file.
Using this, you can have your credentials in one file, completely independent of QGIS.
You can share the project. Other users can use the same project as well, using their own credentials.
The same project can be used by QGIS Server, using other credentials as well.
And you can start saving your ...