Если включена аутентификация:
mongo -u username -p password --authenticationDatabase auth_db_name < your_script.js