You can change the data directory by modifying the storage.dbPath setting in the mongod.conf file.