1. Yes
2. Sometimes the run button of the IDE, sometimes the command line
3. Database connection parameters, API keys and such go in a .dotfile; parameters that might change from run to run usually go in command line argument; special flags for debugging go in environment variables
4. Usually I've got a database (pgsql, arangodb) running as a "service" in the operating system on the local machine. In one case I start up an antivirus server that one application needs.