커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
몽고 DB 접속에서 오류가 발생합니다.
undefined주차
북마크
전*호
댓글
19
추천
0
조회수
242
조회수
242
답변 완료
from pymongo import MongoClient
client = MongoClient('mongodb+srv://headcr:<password>@cluster0.j1vi9.mongodb.net/?retryWrites=true&w=majority')
db = client.headunder

doc = {
    'name':'bob',
    'age':27
}

db.users.insert_one(doc)

C:\Users\user\AppData\Local\Programs\Python\Python310\python.exe C:/Users/user/Desktop/sparta/frontend/dbprac.py

Traceback (most recent call last):

 File "C:\Users\user\Desktop\sparta\frontend\dbprac.py", line 10, in <module>

  db.users.insert_one(doc)

 File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\pymongo\collection.py", line 606, in insert_one

  self._insert_one(

 File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\pymongo\collection.py", line 547, in _insert_one

  self.__database.client._retryable_write(acknowledged, _insert_command, session)

 File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\pymongo\mongo_client.py", line 1399, in _retryable_write

  return self._retry_with_session(retryable, func, s, None)

 File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\pymongo\mongo_client.py", line 1286, in _retry_with_session

  return self._retry_internal(retryable, func, session, bulk)

 File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\pymongo\mongo_client.py", line 1311, in _retry_internal

  with self._get_socket(server, session) as sock_info:

 File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 135, in __enter__

  return next(self.gen)

 File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\pymongo\mongo_client.py", line 1156, in _get_socket

  with server.get_socket(handler=err_handler) as sock_info:

 File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 135, in __enter__

  return next(self.gen)

 File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\pymongo\pool.py", line 1379, in get_socket

  sock_info = self._get_socket()

 File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\pymongo\pool.py", line 1489, in _get_socket

  sock_info = self.connect()

 File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\pymongo\pool.py", line 1350, in connect

  sock_info.authenticate()

 File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\pymongo\pool.py", line 845, in authenticate

  auth.authenticate(creds, self)

 File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\pymongo\auth.py", line 549, in authenticate

  auth_func(credentials, sock_info)

 File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\pymongo\auth.py", line 475, in _authenticate_default

  return _authenticate_scram(credentials, sock_info, "SCRAM-SHA-1")

 File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\pymongo\auth.py", line 241, in _authenticate_scram

  res = sock_info.command(source, cmd)

 File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\pymongo\pool.py", line 743, in command

  return command(

 File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\pymongo\network.py", line 160, in command

  helpers._check_command_response(

 File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\pymongo\helpers.py", line 180, in _check_command_response

  raise OperationFailure(errmsg, code, response, max_wire_version)

pymongo.errors.OperationFailure: bad auth : Authentication failed., full error: {'ok': 0, 'errmsg': 'bad auth : Authentication failed.', 'code': 8000, 'codeName': 'AtlasError'}


Process finished with exit code 1


이렇게 작성하니까 위와 같이 오류가 발생합니다.


취소
 공유
취소
댓글 0
댓글 알림
나의얼굴