解決python MySQLdb import Error問題
今天安裝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 "<stdin>", line 1, in <module>
File "build/bdist.linux-x86_64/egg/MySQLdb/__init__.py", line 19, in <module>
File "build/bdist.linux-x86_64/egg/_mysql.py", line 7, in <module>
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',))
>>>
>>>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15498/viewspace-2132014/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- No module named MYSQLdb 問題解決MySql
- Data Pump Import速度問題之解決過程Import
- Error in GetCurrentDir(): 13 問題分析與解決Error
- syntax error near unexpected token `問題的解決Error
- Ping:Transmit Failed, Error Code 65問題解決MITAIError
- 解決centos7 安裝MySQLdb-python 報錯 方案CentOSMySqlPython
- python & MySQLdb(one)PythonMySql
- 解決「問題」,不要解決問題
- python -- 解決字典【KEY ERROR】PythonError
- mysql登入遇到ERROR 1045問題解決方法MySqlError
- Python import 時要注意的幾個問題PythonImport
- 【Linux+Python】叢集、ssh、python、import errorLinuxPythonImportError
- python待解決問題筆記Python筆記
- npm ERR! Error: CERT_UNTRUSTED的問題解決NPMErrorRust
- Uncaught Error: Bootstrap‘s JavaScript requires jQuery報錯問題解決ErrorbootJavaScriptUIjQuery
- Andorid“emulator: ERROR: unknown virtual device name”問題解決Errordev
- Import Error: cannot import name ‘export_saved_modelImportErrorExport
- 解決SpringBoot頁面localhost 404問題,即Whitelabel Error Page問題Spring BootlocalhostError
- 徹底解決Python編碼問題Python
- python 中文亂碼問題解決方案Python
- configure: error: no acceptable C compiler found in $PATH 問題解決ErrorCompile
- Python 3安裝MySQLdbPythonMySql
- IMP-00013: only a DBA can import a file exported by another DBA 問題及解決方案ImportExport
- 解決問題
- Python從入門到精通(第2版)——pyuic5: error: no such option: -m的問題解決PythonUIError
- React import React 無效問題ReactImport
- openstack上建立vm例項後,狀態為ERROR問題解決Error
- Error:A problem was found with the configuration of task ':app:packageDebug' 問題解決ErrorAPPPackage
- 發現問題,解決問題
- Python 解決 :NameError: name 'reload' is not defined 問題PythonError
- python 生成csv亂碼問題解決方法Python
- 解決python中文編碼錯誤問題Python
- 解決 Jenkins 上 git 出現的 “ERROR: Error fetching remote repo 'origin'” 問題JenkinsGitErrorREM
- Python3出現"No module named 'MySQLdb'"問題-以及使用PyMySQL連線資料庫PythonMySql資料庫
- 【問題解決】remote: parse error: Invalid numeric literal at line 1, column 20,解決思路REMError
- python MySQLdb 配置 python連結MYSQLPythonMySql
- yum問題解決
- sqlitedabaseislocked問題解決SQLite