python的 MySQLdb无法connect的问题
2011-08-16 13:23
260 查看
出现以下错误,有可能是mysql服务器未安装,在ubuntu可以使用apt-get install mysql-server来安装mysql服务器。
>>> import MySQLdb
>>> cxn =MySQLdb.connect(user='root')
Traceback (mostrecent call last):
File "<stdin>", line 1, in<module>
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)")
>>> import MySQLdb
>>> cxn =MySQLdb.connect(user='root')
Traceback (mostrecent call last):
File "<stdin>", line 1, in<module>
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)")
相关文章推荐
- 在ubuntu下python的 MySQLdb无法connect的问题
- Python - MySQLdb.connect连接lampp中mysql服务器问题的解决
- python MySQLdb 问题 - 程序已的后台运行每90秒获取数据,却无法获取最新的值
- OS X 10.11 下Python-MySQLdb无法使用的问题
- MySQLdb-python无法设置字符集的问题
- Python2.7+mysqlDB+mysql5.5.x更新操作无法正常刷新到服务器的问题
- OS X 10.11 下解决Python-MysqlDB无法使用的问题
- windows下用Python连接mysql报错问题“MySQLdb in Python: “Can't connect to MySQL server on 'localhost'””
- window下python无法安装lxml问题解决
- Python学习第一步—解决无法导入自己写的模块的问题
- 解决mysql本地可访问,远程无法访问的问题 Host is not allowed to connect to this MySQL server
- python MySQLdb在windows环境下的快速安装、问题解决方式
- Ubuntu “软件包 libpython3.5-dev 需要重新安装,但是我无法找到相应的安装文件”的问题
- 解决Windows 7/8上安装Cisco AnyConnect *** Client,服务无法启动问题
- python命令行plt中imshow无法显示图片的问题
- Python利用Seaborn画图中关于中文无法正常显示的问题解决
- python MySQLdb安装问题解决
- win7 下解决python 集成编译环境IDLE无法打开的问题。
- Python, MySQLdb 编码问题 UnicodeEncodeError:'latin-1' codec can't encode character ...
- python mysqldb 遇到的问题