There may be a plugin/code or something that only activates if the user is logged in. This plugin/code might have tables in another database (which is a completely acceptable practice).
You need to figure out what it's trying to connect to. Look in your mysql or php error logs.
If that fails, try turning on WP_DEBUG in your config file, and recreate the error. It might give us more details.