解決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
- 【Linux+Python】叢集、ssh、python、import errorLinuxPythonImportError
- 解決SpringBoot頁面localhost 404問題,即Whitelabel Error Page問題Spring BootlocalhostError
- npm ERR! Error: CERT_UNTRUSTED的問題解決NPMErrorRust
- mysql登入遇到ERROR 1045問題解決方法MySqlError
- python -- 解決字典【KEY ERROR】PythonError
- 解決centos7 安裝MySQLdb-python 報錯 方案CentOSMySqlPython
- python & MySQLdb(one)PythonMySql
- 解決 Jenkins 上 git 出現的 “ERROR: Error fetching remote repo 'origin'” 問題JenkinsGitErrorREM
- mysql的ERROR 1231 (42000)問題原因及解決方法MySqlError
- Python import 時要注意的幾個問題PythonImport
- 【問題解決】remote: parse error: Invalid numeric literal at line 1, column 20,解決思路REMError
- Uncaught Error: Bootstrap‘s JavaScript requires jQuery報錯問題解決ErrorbootJavaScriptUIjQuery
- 解決goland 匯入專案後import裡的包報紅問題GoLandImport
- Import Error: cannot import name ‘export_saved_modelImportErrorExport
- Python 解決 :NameError: name 'reload' is not defined 問題PythonError
- 徹底解決Python編碼問題Python
- Python從入門到精通(第2版)——pyuic5: error: no such option: -m的問題解決PythonUIError
- 解決windows下WslRegisterDistribution failed with error: 0x80070050的問題WindowsAIError
- Python 3安裝MySQLdbPythonMySql
- Python的Selenium一些問題解決Python
- 解決idea匯入maven專案報Unable to import maven project: See logs for details問題IdeaMavenImportProjectAI
- Python3出現"No module named 'MySQLdb'"問題-以及使用PyMySQL連線資料庫PythonMySql資料庫
- sublime上配置java環境,解決Decode error - output not utf-8問題JavaError
- ISSAC GYM解決RuntimeError: nvrtc: error: invalid value for --gpu-architecture (-arch)的問題ErrorVRGPU
- python json.dumps中文亂碼問題解決PythonJSON
- VSCode中解決python模組匯入問題VSCodePython
- Python執行緒安全問題及解決方法Python執行緒
- python 使用 最大生成樹 解決 營救問題Python
- Linux:Python報錯:No module named MySQLdbLinuxPythonMySql
- Linux安裝mysql出現ERROR! The server quit without updating PID file問題解決LinuxMySqlErrorServerUI
- linux mint 19 pyenv 安裝 python 3.7.0 問題解決LinuxPython
- Linux解決MySQL-python安裝失敗問題LinuxMySqlPython
- 【譯】Python 是解決任何問題的完美工具Python
- 解決 macOS 下 Python 3.8 安裝 mysqlclient 的問題MacPythonMySqlclient
- Linux安裝Python3.11以及解決openssl問題LinuxPython
- 窮舉法解決0/1揹包問題——pythonPython
- 安裝 python3 後,yum 失效問題解決Python
- 提問題比解決問題更重要