Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Resolve python MySQLdb import Error issu

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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',))

> > >

> > >

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report