How to use MySQLdb with Python and Django in OSX 10.6?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
On OSX 10.6, using Django with MySQL usually meant using the old MySQLdb driver from the MySQL-python package. The main challenge on Snow Leopard was not Django itself, but getting Python, MySQL client libraries, and the compiled extension to agree on architecture and library paths.
Understand What MySQLdb Means on This Stack
Historically, MySQLdb was the Python module provided by the MySQL-python package. In Django settings, you still point the backend at MySQL, but the actual DB-API driver loaded under the hood is MySQLdb.
On a legacy OSX 10.6 setup, the moving parts are:
- Python 2.x
- a local MySQL installation
- development headers and
mysql_config - the
MySQL-pythonextension compiled for the same architecture as Python
If any of those disagree, installation usually fails with compiler or linker errors.
Install MySQL Client Libraries First
Before installing the Python package, make sure MySQL itself is installed and that mysql_config is available:
If mysql_config is missing, the Python extension does not know where to find MySQL headers and libraries.
On an older machine, you may need to add the MySQL bin directory to your shell path:
That does not solve everything, but it is a common first requirement.
Install MySQL-python for the Right Architecture
Snow Leopard often exposed 32-bit versus 64-bit mismatches. If Python is running as x86_64 and the MySQL client libraries are built differently, the extension build or import can fail.
Check your Python architecture:
Then install the driver:
If your environment is truly 32-bit, adjust the architecture flag accordingly. The exact fix depends on the binaries you have installed, but the principle is always the same: Python, MySQL client libraries, and the compiled extension must match.
If pip is not available on that machine, legacy setups sometimes used easy_install, but pip is easier to reason about if you can get it installed.
Configure Django to Use MySQL
Once the driver imports successfully, Django configuration is straightforward:
Then test the connection:
If Django starts and can connect, the Python driver is working.
Verify the Driver Directly
When debugging an old environment, verify the module before blaming Django:
You can also run a direct connection test:
If that fails outside Django, the issue is with the driver or MySQL libraries, not the ORM.
Modern Context
On current systems, mysqlclient replaced the old MySQL-python package. But for an OSX 10.6 era question, MySQLdb usually means working within an old Python 2 and Django stack where MySQL-python was the expected answer.
That matters because many modern installation guides assume newer compilers, newer OpenSSL, and Python 3, which do not map cleanly onto Snow Leopard.
Common Pitfalls
The most common failure is an architecture mismatch between Python and the MySQL client libraries. On older macOS versions, that problem appears often and produces confusing build errors.
Another issue is missing mysql_config. Without it, the extension cannot locate the headers and libraries required during compilation.
Developers also sometimes configure Django correctly but never test whether import MySQLdb works on its own. That wastes time because the import step is usually where the root problem lives.
Finally, keep the legacy context in mind. Advice for mysqlclient on modern Python 3 is useful in general, but it is not a drop-in fix for OSX 10.6.
Summary
- On OSX 10.6,
MySQLdbusually comes from theMySQL-pythonpackage. - Install MySQL first and make sure
mysql_configis on your path. - Match the architecture of Python, MySQL libraries, and the compiled extension.
- Verify
import MySQLdbbefore debugging Django settings. - In Django, use
django.db.backends.mysqland test the connection with management commands.
Related reading
- How to use MySQLdb with Python and Django in OSX 10.6?
- how to use pymysql executemany insert many rows and get the ids of each rows
- How to use Spring Boot with MySQL database and JPA?
- How to use Spring managed Hibernate interceptors in Spring Boot?
- How to use pass statement?
- How to use pip with Python 3.x alongside Python 2.x
- How to use the dumped data by mongodump?
- How to use the Kafka Connect JDBC to source PostgreSQL with multiple schemas that contain tables with the same name?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.