To change the database connection in PyMongo, you need to first create a new MongoClient object with the desired connection details. You can specify the host, port, username, password, or any other relevant connection parameters when creating this new client object. Once you have the new client object, you can use it to access the desired database and collection using the dot notation or dictionary style access.