问题
I have installed MySQLdb for python, and have the following code.
import MySQLdb
conn = MySQLdb.connect(host="hello")
Everytime I run this on terminal, I get Segmentation fault (core dumped)
But when I put the above lines in hi.py file, and run python hi.py, then I do not see this error in terminal.
Could anyone give me an advice to fix this problem?
$ python
>>> import MySQLdb
>>> conn = MySQLdb.connect(host="hello")
Segmentation fault (core dumped)
This is the command I typed in the terminal. And got segmentation fault error.
回答1:
I have encountered a similar problem before, try checking if you are using python2 with the terminal.
MySQLdb does not work with python3. If you want to work with python3 use mysql-connector-python
You can install it with pip
: pip install mysql-connector-python
来源:https://stackoverflow.com/questions/33112469/segmentation-fault-mysqldb