I got totally lost and confused with all this different connection settings. For me, it worked this way:
- Create the different environments / targets, but did not enter database details in the project settings (not sure what their are for)
- Select your environment (bottom left), go to globals / database connection / your db connection (only one is required!) and open the connection options. Enter the database settings for the selected environment.
- Close(!) that db connection tab (Important, otherwise the settings are not refreshed after the following switch!)
- Switch your target to production (or how your publishing target is called)
- Open your DB connection and enter for production. Again, save and close(!) the tab.
- Now every publishing target has its own settings.
I had similar challenges, you find a bit more info here: