解决pythonMySQLdbimportError问题

 
今天安装MySQLmtop的时候报错,发现没有安装python的MySQLdb模块,手动运行报如下错:
[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
>>>

解决方法:
root@test1 mysqlmtop]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/
[root@test1 mysqlmtop]#

再次运行测试:
[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',))
>>>
>>>



当前文章:解决pythonMySQLdbimportError问题
转载源于:http://bzwzjz.com/article/pehohp.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 成都网站建设 企业网站建设 成都网站设计 网站设计制作 定制级高端网站建设 高端定制网站设计 重庆企业网站建设 高端网站设计 定制网站建设 网站建设 成都网站设计公司 成都网站建设 成都网站建设公司 高端网站设计推广 手机网站建设套餐 网站设计制作报价 成都网站设计 响应式网站建设 成都网站建设公司 成都网站制作 成都响应式网站建设 阿坝网站设计