Installing MySQL-python without mysql-server on CentOS

丶灬走出姿态 提交于 2019-12-03 09:32:40

问题


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.




回答3:


I'm using RHEL 7 and have de same question

sudo yum install mariadb-devel

works fine to me :)

note: above comment was edited to remove the typo



来源:https://stackoverflow.com/questions/13922955/installing-mysql-python-without-mysql-server-on-centos

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!