您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息

django与数据库的同步终于成功了!!mark一下

2024/4/27 1:37:03发布6次查看
在安装django的时候,出现错误: connect: _mysql_exceptions.operationalerror: (2002, can't connect to local mysql server through socket '/tmp/mysql.sock' (2)); 客户端在连接服务端的时候,需要找到mysql.sock 请看这篇文章 http://blog.5ilinux.c
在安装django的时候,出现错误:
connect: _mysql_exceptions.operationalerror: (2002, can't connect to local mysql server through socket '/tmp/mysql.sock' (2));
客户端在连接服务端的时候,需要找到mysql.sock
请看这篇文章
http://blog.5ilinux.com/archives/2005/06/mysqlmysqlsock.html
解决应用程序调用mysql的找不到mysql.sock的问题新的mt系统,我使用了mysql系统,一直用的很好,不过今天我偶然去使用phpmyadmin时,居然报can't connect to local mysql server through socket '/var/lib/mysql/mysql.sock'的错误。奇怪,明明mysql正常启动,但为什么phpmyadmin不能正常连接mysql,然后又直接去linux机器,本地运行mysql命令,发现mysql确实正常运行起来,看来是phpmyadmin的问题,马上去找phpmyadmin的配置文件,发现确实有设置mysql.sock文件的位置,由于安装mt的缘故,我把mysql.sock选择在/tmp/mysql.sock。修改之下,phpmyadmin正常运行,但随之我又发现我的另外一个blog系统wp也不能正常调用mysql,它也是一个php的blog,但这个程序确没地方设置mysql.sock的位置,左思右想发现php.ini有修改mysql.sock的设置,只要在这里设置了,所有的php应用就再也不报以上错误。通过以上调试总结出以下结论:
当出些类似can't connect to local mysql server through socket '/var/lib/mysql/mysql.sock'的错误时,解决方法:
1.mysql可能没正常启动,检查mysql程序
2.修改/etc/my.cnf 修改mysql.sock的位置,使之满足php或者cgi程序的需要
3.修改php.ini的mysql.sock的设置,满足所有php程序的需要
4.修改某些程序中配置文件中关于mysql.sock的设置。
 我得益于这篇文章,
http://trac.turbogears.org/turbogears/wiki/sockfile
problem ¶i want to use turbo gears, but my machine is setup with mysql not bound to a network socket and i get the following errors when i try to connect: _mysql_exceptions.operationalerror: (2002, can't connect to local mysql server through socket '/tmp/mysql.sock' (2));
solution ¶there is a practice of not binding mysql to an ip address and port following the principle that if you're not connected, you are protected. in this situation, the server has a socket file. by default turbogears (or sqlobject and the python mysql driver/client to be more exact) will look for the socket file in /tmp/mysql.sock. many installations seem to use /var/lib/mysql/mysql.sock. therefore, to get turbogears to work, you'll need to specify the unix_socket (if on unix) param in the dburi. you can find out where your mysql socket is by looking at the file my.cnf that usually resides in /etc/my.cnf or /etc/mysql/my.cnf.
format: sqlobject.dburi=mysql://username:password@/databasename?unix_socket=path-to-mysql.sock
example: i have my socket file in /var/lib/mysql/mysql.sock and i want my user foo with password bar to connect to my db test1. sqlobject.dburi=mysql:/foo:bar@/test1?unix_socket=/var/lib/mysql/mysql.sock
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录