Fix: Python's mysqlclient broken with MySQL 8.3.0 on Mac with Homebrew

· 209 words · 1 minute read

At Hungryroot we use AWS’ Aurora MySQL with some of our Django projects. This morning, a few of our developers, working on Mac OS with Homebrew, reported that their mysqlclient libraries were erroring out with:

'/opt/homebrew/Cellar/mysql-client/8.3.0/lib/libmysqlclient.22.dylib' (no such file)

Attempts to reinstall the mysqlclient Python library were failing with:

clang -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/opt/homebrew/opt/mysql-client/include "-Dversion_info=(2, 2, 1, 'final', 0)" -D__version__=2.2.1 -I/Users/avishekde/.pyenv/versions/3.11.6/include/python3.11 -c src/MySQLdb/_mysql.c -o build/temp.macosx-14.1-arm64-cpython-311/src/MySQLdb/_mysql.o -I/opt/homebrew/Cellar/mysql-client/8.3.0/include/mysql -std=c99
src/MySQLdb/_mysql.c:527:9: error: call to undeclared function 'mysql_ssl_set'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
            mysql_ssl_set(&(self->connection), key, cert, ca, capath, cipher);
              ^

It turns out that the recently released MySQL 8.3.0 removed some APIs that the Python mysqlclient depended upon, as documented in this GitHub issue.

It has been fixed in mysqlclient version 2.2.4, however you shouldn’t just go upgrading a core dependency like that without some testing and examination of the changelog. So to get yourself out of this mess:

  1. Download this file – the Homebrew formula for MySQL 8.2.0
  2. brew uninstall mysql-client
  3. brew install ~/Downloads/mysql-client.rb (or modify with whatever path you saved the downloaded file to)
  4. brew pin mysql-client

That should get you back in business.

Once you upgrade to 2.2.4, you should brew unpin mysql-client and let Homebrew resume managing that dependency.