Get the App
SLTechnology News&Howtos  ›  Database  › 

Resolve python MySQLdb import Error issu

Shulou Source: shulou.com Published: 2022-06-01 06:54:13 09月13日 Update

An error was reported when installing MySQLmtop today. It was found that the MySQLdb module of python was not installed. Manual operation reported the following error:

[root@test1 mysqlmtop] # python

Python 2.6.6 (r266 84292, Aug 18 2016, 15:13:37)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

> import MySQLdb

Traceback (most recent call last):

File "", line 1, in

File "build/bdist.linux-x86_64/egg/MySQLdb/__init__.py", line 19, in

File "build/bdist.linux-x86_64/egg/_mysql.py", line 7, in

File "build/bdist.linux-x86_64/egg/_mysql.py", line 6, in _ _ bootstrap__

ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory

> quit

Use quit () or Ctrl-D (i.e. EOF) to exit

> > >

Solution:

Root@test1 mysqlmtop] # ln-s / usr/local/mysql/lib/libmysqlclient.so.18 / usr/lib64/

[root@test1 mysqlmtop] #

Run the test again:

[root@test1 mysqlmtop] # python

Python 2.6.6 (r266 84292, Aug 18 2016, 15:13:37)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

> import MySQLdb

> > >

> conn= MySQLdb.connect

... Host='172.16.16.14'

... Port = 3306

... User='root'

... Passwd='123456'

... Db = 'test'

.)

> > cur = conn.cursor ()

> > >

> cur.execute ("select * from chenfeng")

3L

> > >

> > result = cur.fetchall ()

> print result

(('aaaa',), (' bbbb',), ('bbbb',))

> > >

> > >

Tags: Run again manual method time module i.e. test problem Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Shulou Information OPPO Reno Huawei Docker