I am trying to get a Python script to run on the linux server I'm connected to via ssh. The script uses mysqldb. I have all the other components I need, but when I try to install mySQLdb via setuptools like so:,
python setup.py install
I get the following error report related to the mysql_config
command.
sh: mysql_config: command not found
Traceback (most recent call last):
File "setup.py", line 15, in <module>
metadata, options = get_config()
File "/usr/lib/python2.5/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "/usr/lib/python2.5/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
Has anyone else encountered this error and if so how did you resolve it/what can I do to successfully install mysqldb?
The commands (mysql too) mPATH might be missing.
export PATH=$PATH:/usr/local/mysql/bin/
mySQLdb is a python interface for mysql, but it is not mysql itself. And apparently mySQLdb needs the command 'mysql_config', so you need to install that first.
Can you confirm that you did or did not install mysql itself, by running "mysql" from the shell? That should give you a response other than "mysql: command not found".
Which linux distribution are you using? Mysql is pre-packaged for most linux distributions. For example, for debian / ubuntu, installing mysql is as easy as
mysql-config is in a different package, which can be installed from (again, assuming debian / ubuntu):
if you are using mariadb, the drop in replacement for mysql, then run
(Specific to mac) I have tried a lot many things, but these set of commands finally worked for me.
brew install mysql
# install mysqlbrew unlink mysql
brew install mysql-connector-c
export PATH=/usr/local/Cellar/mysql/8.0.11/bin:$PATH
# update path and set the mysql bin folder to pathsudo ln -s /usr/local/Cellar/mysql/8.0.11/lib/libmysqlclient.21.dylib /usr/local/Cellar/lib/libmysqlclient.21.dylib
# create symlinkpip install mysqlclient
# install mysql-client finallyThe below worked for me on Ubuntu 12.04 LTS:
All though it worked, i still went ahead to do the below:
Just type:
This will solve this problems.
If you're on macOS and already installed mysql@5.7 via brew install:
brew install mysql-connector-c
brew unlink mysql@5.7
brew link --overwrite --dry-run mysql@5.7
first, to see what symlinks are getting overwrittenbrew link --overwrite --force mysql@5.7
to actually overwrite mysql-related symlinks with mysql@5.7pip install mysqlclient