zoukankan      html  css  js  c++  java
  • 在ubuntu下python的 MySQLdb无法connect的问题

    安装了python-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)")

    结果出现"Can't connect to local MySQL server through socket'/var/run/mysqld/mysqld.sock' (2)"。

    原因是mysql服务器未安装,在ubuntu可以使用apt-get install mysql-server来安装mysql服务器。

  • 相关阅读:
    注释
    Java三种嵌入jsp的方法
    JSP page指令
    Web应用的目录结构
    Tomcat安装和配置
    动态网页和静态网页的区别
    B/S架构与C/S架构的区别
    URL
    常用SQL查询语句
    SQL--Delete语句
  • 原文地址:https://www.cnblogs.com/zzcflying/p/2601014.html
Copyright © 2011-2022 走看看