I'm attempting to install MySQL-python on a machine running CentOS 5.5 and python 2.7. This machine isn't running a mysql server, the mysql instance this box will be using is hosted on a separate server. I do have a working mysql client. On attempting sudo pip install MySQL-python
, I get an error of EnvironmentError: mysql_config not found
, which as far as I can tell is a command that just references /etc/my.cnf
, which also isn't present. Before I go on some wild goose chase creating spurious my.cnf files, is there an easy way to get MySQL-python installed?
问题:
回答1:
So it transpires that mysql_config is part of mysql-devel. mysql-devel is for compiling the mysql client, not the server. Installing mysql-devel allows the installation of MySQL-python.
回答2:
I couldn't find a question specific to CentOS 6.x, and this solution doesn't work out of the box for that platform. I'll post my discovery here in the hope that it helps the next poor soul who encounters the problem.
The CentOS Yum repository serves up a version of the MariaDB distributions that don't include mysql_config. To fix, add a file containing something like the following to /etc/yum.repos.d/MariaDB.repo:
# MariaDB 5.5 CentOS repository list - created 2016-04-21 20:25 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
This is the repo config specified (for CentOS 6 and MariaDB 5.5) by MariaDB at https://downloads.mariadb.org/mariadb/repositories/. Of course if your environment differs you should go through the configurator at that URL.
Once you've done that, you may need to call
yum remove MariaDB-devel
yum clean metadata
yum install MariaDB-devel
Then give the Pip install a try.