Installing MySQLdb for python2.7 in RHEL 6

423 views
Skip to first unread message

Larry Martell

unread,
Feb 22, 2016, 9:17:58 PM2/22/16
to django...@googlegroups.com
Not strictly a django question, but it's something required to get
django running.

I am trying to get django 1.9 running in RHEL 6. I have installed
python2.7 and when I try to install MySQLdb, I get the errors shown
below. I have googled and googled and tried many different things, all
with no success. Can anyone please let me know how I can get this
going?

# /usr/local/bin/pip2.7 install MySQL-python
Collecting MySQL-python
Downloading MySQL-python-1.2.5.zip (108kB)
100% |████████████████████████████████| 110kB 3.2MB/s
Installing collected packages: MySQL-python
Running setup.py install for MySQL-python ... error
Complete output from command /usr/local/bin/python2.7 -u -c
"import setuptools,
tokenize;__file__='/tmp/pip-build-SPMNQU/MySQL-python/setup.py';exec(compile(getattr(tokenize,
'open', open)(__file__).read().replace('\r\n', '\n'), __file__,
'exec'))" install --record /tmp/pip-QrpP1S-record/install-record.txt
--single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
copying _mysql_exceptions.py -> build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb
creating build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py ->
build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CR.py ->
build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py ->
build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/ER.py ->
build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py ->
build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py ->
build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py ->
build/lib.linux-x86_64-2.7/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.linux-x86_64-2.7
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3
-Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,5,'final',1)
-D__version__=1.2.5 -I/usr/include/mysql
-I/usr/local/include/python2.7 -c _mysql.c -o
build/temp.linux-x86_64-2.7/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2
-fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64
-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
-fno-strict-aliasing -fwrapv -fPIC -fPIC -g -static-libgcc
-fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1
_mysql.c:44:23: error: my_config.h: No such file or directory
_mysql.c:46:19: error: mysql.h: No such file or directory
_mysql.c:47:26: error: mysqld_error.h: No such file or directory
_mysql.c:48:20: error: errmsg.h: No such file or directory
_mysql.c:88: error: expected specifier-qualifier-list before ‘MYSQL’
_mysql.c:102: error: expected specifier-qualifier-list before ‘MYSQL_RES’
_mysql.c: In function ‘_mysql_Exception’:
_mysql.c:146: warning: implicit declaration of function ‘mysql_errno’
_mysql.c:146: error: ‘_mysql_ConnectionObject’ has no member named
‘connection’
_mysql.c:149: error: ‘CR_MAX_ERROR’ undeclared (first use in this function)
_mysql.c:149: error: (Each undeclared identifier is reported only once
_mysql.c:149: error: for each function it appears in.)
_mysql.c:161: error: ‘CR_COMMANDS_OUT_OF_SYNC’ undeclared (first
use in this function)
_mysql.c:162: error: ‘ER_DB_CREATE_EXISTS’ undeclared (first use
in this function)
_mysql.c:163: error: ‘ER_SYNTAX_ERROR’ undeclared (first use in
this function)
_mysql.c:164: error: ‘ER_PARSE_ERROR’ undeclared (first use in
this function)
_mysql.c:165: error: ‘ER_NO_SUCH_TABLE’ undeclared (first use in
this function)
_mysql.c:166: error: ‘ER_WRONG_DB_NAME’ undeclared (first use in
this function)
_mysql.c:167: error: ‘ER_WRONG_TABLE_NAME’ undeclared (first use
in this function)
_mysql.c:168: error: ‘ER_FIELD_SPECIFIED_TWICE’ undeclared (first
use in this function)
_mysql.c:169: error: ‘ER_INVALID_GROUP_FUNC_USE’ undeclared (first
use in this function)
_mysql.c:170: error: ‘ER_UNSUPPORTED_EXTENSION’ undeclared (first
use in this function)
_mysql.c:171: error: ‘ER_TABLE_MUST_HAVE_COLUMNS’ undeclared
(first use in this function)
_mysql.c:200: error: ‘ER_DUP_ENTRY’ undeclared (first use in this function)
_mysql.c:246: warning: implicit declaration of function ‘mysql_error’
_mysql.c:246: error: ‘_mysql_ConnectionObject’ has no member named
‘connection’
_mysql.c: In function ‘_mysql_server_init’:
_mysql.c:351: warning: label ‘finish’ defined but not used
_mysql.c:268: warning: unused variable ‘item’
_mysql.c:267: warning: unused variable ‘groupc’
_mysql.c:267: warning: unused variable ‘i’
_mysql.c:267: warning: unused variable ‘cmd_argc’
_mysql.c:266: warning: unused variable ‘s’
_mysql.c: In function ‘_mysql_ResultObject_Initialize’:
_mysql.c:406: error: ‘MYSQL_RES’ undeclared (first use in this function)
_mysql.c:406: error: ‘result’ undeclared (first use in this function)
_mysql.c:411: error: ‘MYSQL_FIELD’ undeclared (first use in this function)
_mysql.c:411: error: ‘fields’ undeclared (first use in this function)
_mysql.c:425: error: ‘_mysql_ResultObject’ has no member named ‘use’
_mysql.c:428: warning: implicit declaration of function ‘mysql_use_result’
_mysql.c:428: error: ‘_mysql_ConnectionObject’ has no member named
‘connection’
_mysql.c:430: warning: implicit declaration of function ‘mysql_store_result’
_mysql.c:430: error: ‘_mysql_ConnectionObject’ has no member named
‘connection’
_mysql.c:431: error: ‘_mysql_ResultObject’ has no member named ‘result’
_mysql.c:434: warning: implicit declaration of function ‘mysql_field_count’
_mysql.c:434: error: ‘_mysql_ConnectionObject’ has no member named
‘connection’
_mysql.c:438: error: ‘_mysql_ResultObject’ has no member named ‘converter’
_mysql.c:442: warning: implicit declaration of function ‘mysql_num_fields’
_mysql.c:443: error: ‘_mysql_ResultObject’ has no member named ‘nfields’
_mysql.c:444: error: ‘_mysql_ResultObject’ has no member named ‘converter’
_mysql.c:448: warning: implicit declaration of function ‘mysql_fetch_fields’
_mysql.c:489: error: ‘BINARY_FLAG’ undeclared (first use in this function)
_mysql.c:512: error: ‘_mysql_ResultObject’ has no member named ‘converter’
_mysql.c: In function ‘_mysql_ResultObject_traverse’:
_mysql.c:526: error: ‘_mysql_ResultObject’ has no member named ‘converter’
_mysql.c:527: error: ‘_mysql_ResultObject’ has no member named ‘converter’
_mysql.c: In function ‘_mysql_ResultObject_clear’:
_mysql.c:538: error: ‘_mysql_ResultObject’ has no member named ‘converter’
_mysql.c:538: error: ‘_mysql_ResultObject’ has no member named ‘converter’
_mysql.c:538: error: ‘_mysql_ResultObject’ has no member named ‘converter’
_mysql.c:538: error: ‘_mysql_ResultObject’ has no member named ‘converter’
_mysql.c:539: error: ‘_mysql_ResultObject’ has no member named ‘converter’
_mysql.c: In function ‘_mysql_ConnectionObject_Initialize’:
_mysql.c:551: error: ‘MYSQL’ undeclared (first use in this function)
_mysql.c:551: error: ‘conn’ undeclared (first use in this function)
_mysql.c:584: error: ‘_mysql_ConnectionObject’ has no member named
‘converter’
_mysql.c:585: error: ‘_mysql_ConnectionObject’ has no member named ‘open’
_mysql.c:636: warning: implicit declaration of function ‘mysql_init’
_mysql.c:636: error: ‘_mysql_ConnectionObject’ has no member named
‘connection’
_mysql.c:639: warning: implicit declaration of function ‘mysql_options’
_mysql.c:639: error: ‘_mysql_ConnectionObject’ has no member named
‘connection’
_mysql.c:639: error: ‘MYSQL_OPT_CONNECT_TIMEOUT’ undeclared (first
use in this fun

Kelvin Wong

unread,
Feb 22, 2016, 10:07:27 PM2/22/16
to Django users
Install the MariaDB/MySQL header files.

# yum install mysql-devel

or

# yum install MariaDB.devel

Depends on what fork you are planning on running

K

Larry Martell

unread,
Feb 22, 2016, 10:10:34 PM2/22/16
to django...@googlegroups.com
That failed:

# yum install mysql-devel
Loaded plugins: dellsysid, product-id, refresh-packagekit, security,
subscription-manager
Setting up Install Process
Package mysql-devel is obsoleted by mysql-community-devel, trying to
install mysql-community-devel-5.7.11-1.el6.x86_64 instead
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-devel.x86_64 0:5.7.11-1.el6 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) = 5.7.11-1.el6
for package: mysql-community-devel-5.7.11-1.el6.x86_64
--> Processing Dependency: libmysqlclient.so.20()(64bit) for package:
mysql-community-devel-5.7.11-1.el6.x86_64
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.7.11-1.el6 will be obsoleting
--> Processing Dependency: mysql-community-common(x86-64) =
5.7.11-1.el6 for package: mysql-community-libs-5.7.11-1.el6.x86_64
---> Package mysql-libs.x86_64 0:5.5.44-1.el6.remi will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package:
php-mysql-5.4.43-1.el6.remi.x86_64
--> Processing Dependency:
libmysqlclient.so.18(libmysqlclient_16)(64bit) for package:
php-mysql-5.4.43-1.el6.remi.x86_64
--> Processing Dependency:
libmysqlclient.so.18(libmysqlclient_18)(64bit) for package:
php-mysql-5.4.43-1.el6.remi.x86_64
--> Processing Dependency: real-mysql-libs(x86-64) = 5.5.44-1.el6.remi
for package: mysql-server-5.5.44-1.el6.remi.x86_64
--> Processing Dependency: real-mysql-libs(x86-64) = 5.5.44-1.el6.remi
for package: mysql-5.5.44-1.el6.remi.x86_64
--> Running transaction check
---> Package mysql.x86_64 0:5.5.44-1.el6.remi will be obsoleted
---> Package mysql-community-client.x86_64 0:5.7.11-1.el6 will be obsoleting
---> Package mysql-community-common.x86_64 0:5.7.11-1.el6 will be installed
---> Package mysql-community-server.x86_64 0:5.7.11-1.el6 will be obsoleting
---> Package mysql-libs.x86_64 0:5.5.44-1.el6.remi will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package:
php-mysql-5.4.43-1.el6.remi.x86_64
--> Processing Dependency:
libmysqlclient.so.18(libmysqlclient_16)(64bit) for package:
php-mysql-5.4.43-1.el6.remi.x86_64
--> Processing Dependency:
libmysqlclient.so.18(libmysqlclient_18)(64bit) for package:
php-mysql-5.4.43-1.el6.remi.x86_64
---> Package mysql-server.x86_64 0:5.5.44-1.el6.remi will be obsoleted
--> Finished Dependency Resolution
Error: Package: php-mysql-5.4.43-1.el6.remi.x86_64 (@remi)
Requires: libmysqlclient.so.18(libmysqlclient_16)(64bit)
Removing: mysql-libs-5.5.44-1.el6.remi.x86_64 (@remi)
libmysqlclient.so.18(libmysqlclient_16)(64bit)
Obsoleted By: mysql-community-libs-5.7.11-1.el6.x86_64
(mysql57-community)
Not found
Error: Package: php-mysql-5.4.43-1.el6.remi.x86_64 (@remi)
Requires: libmysqlclient.so.18()(64bit)
Removing: mysql-libs-5.5.44-1.el6.remi.x86_64 (@remi)
libmysqlclient.so.18()(64bit)
Obsoleted By: mysql-community-libs-5.7.11-1.el6.x86_64
(mysql57-community)
Not found
Error: Package: php-mysql-5.4.43-1.el6.remi.x86_64 (@remi)
Requires: libmysqlclient.so.18(libmysqlclient_18)(64bit)
Removing: mysql-libs-5.5.44-1.el6.remi.x86_64 (@remi)
libmysqlclient.so.18(libmysqlclient_18)(64bit)
Obsoleted By: mysql-community-libs-5.7.11-1.el6.x86_64
(mysql57-community)
Not found
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest

Kelvin Wong

unread,
Feb 22, 2016, 10:20:15 PM2/22/16
to Django users
You need to locate the header files in order for that to compile.

You might want to see if they are located somewhere on your system by using 'find' or else check 'yum list installed' to see if you have already installed the mysql devel package for your version of the database server (i'm guessing that you haven't got the headers).

If you haven't got them on your machine then you have to install them.

K

Larry Martell

unread,
Feb 22, 2016, 10:37:43 PM2/22/16
to django...@googlegroups.com
Not really sure what I am looking for or what to do.

# yum list installed | grep mysql
compat-mysql51.x86_64 5.1.54-1.el6.remi @remi
mysql.x86_64 5.5.44-1.el6.remi @remi
mysql-libs.x86_64 5.5.44-1.el6.remi @remi
mysql-server.x86_64 5.5.44-1.el6.remi @remi
mysql57-community-release.noarch el6-7
@/mysql57-community-release-el6-7.noarch
php-mysql.x86_64 5.4.43-1.el6.remi @remi

I don't see the devel package, but when I try to install it it fails
as shown below.

Kelvin Wong

unread,
Feb 23, 2016, 2:12:22 AM2/23/16
to Django users
You are mixing the repos (remi and the regular redhat one). You should decide which one you want to use for mysql and stick to it.

The remi repo has the devel package available


You can isolate a repo to see what it offers

$ yum --disablerepo "*" --enablerepo "remi" list available 

K

Larry Martell

unread,
Feb 23, 2016, 6:44:50 AM2/23/16
to django...@googlegroups.com
This is a machine I have inherited and I really know nothing about it.
I need to set up django on it, but I don't want to break anything.
They use the Semantic Media Wiki, which uses PHP - If I do this could
that break that?

Larry Martell

unread,
Feb 23, 2016, 7:20:38 AM2/23/16
to django...@googlegroups.com
I did this:

# yum shell --enablerepo=remi
> remove php-mysql
> install php-mysqlnd
> run

Followed by this:

yum install mysql-devel
/usr/local/bin/pip2.7 install MySQL-python

Now the MySQL server is down and will not come up. It fails with this:

Fatal error: mysql.user table is damaged. Please run mysql_upgrade

Looks like 5.7 is now installed whereas before it was running 5.5
(Server version: 5.5.44 MySQL Community Server (GPL) by Remi') It
fails on start up with Fatal error: mysql.user table is damaged.
Please run mysql_upgrade But how can I run mysql_upgrade if I can't
start the server?
Reply all
Reply to author
Forward
0 new messages