본문 바로가기
 

하나성경

읽기 쉬운 성경, 하나성경을 소개합니다.

www.hbible.co.kr

컴퓨터에서는

[ Django ] mysqlclient 설치 오류

by 컴 여행자 2025. 4. 18.
728x90
반응형

 

장고
장고

 

 

mysqlclient 설치 오류



src/MySQLdb/_mysql.c:556:44: error: ‘MYSQL_OPT_SSL_CA’ undeclared (first use in this function); did you mean ‘MYSQL_OPT_NONBLOCK’?
556 | mysql_options(&(self->connection), MYSQL_OPT_SSL_CA, ca);
| ^~~~~~~~~~~~~~~~
| MYSQL_OPT_NONBLOCK
src/MySQLdb/_mysql.c:557:44: error: ‘MYSQL_OPT_SSL_CAPATH’ undeclared (first use in this function)
557 | mysql_options(&(self->connection), MYSQL_OPT_SSL_CAPATH, capath);
| ^~~~~~~~~~~~~~~~~~~~
src/MySQLdb/_mysql.c:558:44: error: ‘MYSQL_OPT_SSL_CIPHER’ undeclared (first use in this function)
558 | mysql_options(&(self->connection), MYSQL_OPT_SSL_CIPHER, cipher);
| ^~~~~~~~~~~~~~~~~~~~
src/MySQLdb/_mysql.c:579:44: error: ‘MYSQL_OPT_SSL_ENFORCE’ undeclared (first use in this function)
579 | mysql_options(&(self->connection), MYSQL_OPT_SSL_ENFORCE, (void *)&my_true);
| ^~~~~~~~~~~~~~~~~~~~~
src/MySQLdb/_mysql.c:488:10: warning: variable ‘ssl_mode_set’ set but not used [-Wunused-but-set-variable]
488 | char ssl_mode_set = 0;
| ^~~~~~~~~~~~
error: command '/opt/rh/devtoolset-11/root/usr/bin/gcc' failed with exit code 1
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for mysqlclient
Failed to build mysqlclient
ERROR: Failed to build installable wheels for some pyproject.toml based projects (mysqlclient)

    

 

 

현재 CentOS 7 환경에서 MySQL 클라이언트 버전이 5.5.68임을 확인하셨고, mysqlclient 최신 버전(2.2.7) 설치 시
MYSQL_OPT_SSL_KEY 등 SSL 관련 심볼이 정의되지 않아 빌드가 실패하고 있습니다.

 

이 문제는 MySQL 5.5 개발 라이브러리가 너무 구버전이라 최신 mysqlclient와 호환되지 않기 때문입니다.
mysqlclient 2.2.x는 MySQL 5.6 이상, 특히 5.7 이상을 권장하며, 5.5에서는 SSL 옵션 등 일부 심볼이 아예 존재하지 않습니다.

해결 방법

1. 구버전 mysqlclient 설치

 

MySQL 5.5와 호환되는 마지막 mysqlclient 버전(2.0.3)을 설치하세요.

pip install 'mysqlclient<2.1.0'
 
 
  • 2.0.x 버전은 MySQL 5.5와의 호환성이 유지됩니다.
  • 최신 기능은 없지만, Django 등에서 기본적인 MySQL 연동은 문제없이 동작합니다.

2. MySQL 클라이언트 업그레이드 (권장)

가능하다면 MySQL 클라이언트 라이브러리를 5.7 이상(최소 5.6)으로 업그레이드하세요.

  • CentOS 7 기본 저장소에는 5.5만 있으므로, Remi 저장소 또는 MySQL 공식 저장소를 추가해야 합니다.
  • 업그레이드가 어렵다면 1번 방법을 사용하세요.

3. 대안: PyMySQL 사용

C 확장 모듈 없이 100% 파이썬으로 구현된 PyMySQL을 사용할 수도 있습니다.

pip install PyMySQL
 
 

Django에서는 settings.py의 ENGINE을 'django.db.backends.mysql'로 두고,
__init__.py에 아래 코드를 추가하면 PyMySQL을 자동으로 사용합니다.

 

import pymysql
pymysql.install_as_MySQLdb()
 
 

단, 성능이 mysqlclient보다 다소 떨어질 수 있습니다.

 

결론

  • MySQL 5.5에서는 최신 mysqlclient(2.2.x) 설치가 불가능합니다.
  • pip install 'mysqlclient<2.1.0'으로 2.0.x 버전을 설치하면 해결됩니다.
  • 장기적으로는 MySQL 클라이언트 업그레이드 또는 PyMySQL로 전환을 권장합니다.

참고:
"mysqlclient fails to build for MySQL >= 8.3.0" 이슈와 달리,
MySQL 5.5에서는 SSL 관련 심볼이 아예 없으므로 최신 mysqlclient 빌드가 불가합니다.
구버전 사용이 유일한 실질적 해결책입니다.

 

 

※ 주의사항 : 일부 내용은 AI와 나눈 대화를 정리한 것이므로 이 점을 고려해서 읽으시기를 권장합니다.

 

https://www.djangoproject.com/

 

Django

The web framework for perfectionists with deadlines.

www.djangoproject.com

 

 

728x90
반응형

댓글