出现以下错误,有可能是mysql服务器未安装,在ubuntu可以使用apt-get install mysql-server来安装mysql服务器。
>>> import MySQLdb
>>> cxn =MySQLdb.connect(user='root')
Traceback (mostrecent call last):
File "
File"/usr/lib/pymodules/python2.6/MySQLdb/__init__.py", line 81, inConnect
return Connection(*args, **kwargs)
File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py",line 170, in __init__
super(Connection, self).__init__(*args,**kwargs2)
_mysql_exceptions.OperationalError:(2002, "Can't connect to local MySQL server through socket'/var/run/mysqld/mysqld.sock' (2)")