I just resolved this exact issue when running Ansible’s mysql_user module. The answer here helped tip me off to a solution. I also needed MySQL-python from pip, which also broke in this process, so I’ve added the extra steps.
Steps to resolve:
brew unlink mysql # only if installed, causes the next step to failbrew install mysql-connector-c- locate
mysql_configfile withwhich (mysql_config) - edit the
mysql_configfile, under# Create optionschange this:libs="$libs -l "to this:libs="$libs -lmysqlclient -lssl -lcrypto"if using vim,:wq!to save the read-only file - Now the install should run successfully
pip install mysqlclient - Adding this separately, as it’s similar but not directly related to the initial question
pip install MySQL-python - Fix
mysqlbrew formula, if it was unlinked in the first step.brew unlink mysql-connector-cbrew link mysql