Is this P6 EPPM 8.2 or P6 PPM? Are you using P6 client or web to connect to it?
If this is P6EPPM then you can log into P6 Administrator and expand database node, create a duplicate node of it and change the database connection parameters. Save it and try to login using P6 Web. Select the correct database from Advance link below Username/Password.
If this is P6 PPM then define tns entries on your machine for both the databases ans use them to configure P6 client.