django与数据库的同步终于成功了!!mark一下
2006-07-27 10:45
423 查看
在安装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
当出些类似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
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"
addHeadingLinks(document.getElementById("searchable"));
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"
addHeadingLinks(document.getElementById("searchable"));
相关文章推荐
- django 删除数据库表后重新同步
- django 1.9 同步数据库bug
- django south实现数据库同步
- 纪念一下--ECLIPSE+JLINK单步调试OK6410终于成功
- django1.11.1 models 数据库同步
- 用于Django工程数据库同步改动的South
- Django进阶Model篇003 - 数据库同步技巧
- Django1.9 models数据库同步问题
- django之创建第8个项目-数据库配置及同步研究
- 庆祝一下:配了2周终于把skyeye+uClinux配置成功!
- Django修改model如何同步数据库
- django model改变后,同步数据库
- Django 修改model后同步修改数据库
- centOS中文支持问题,终于解决了。mark一下
- django 增加字段后同步不上数据库
- No migrations to apply.(django不能创建数据库中的表的问题) Django 1.10.1下操作成功的案例
- django 删除数据库表后重新同步的方法
- django 数据库同步
- Django中的一些同步Model和数据库的命令
- django程序没有问题,保存远地测试数据库,save没问题,控制台也显示update成功,但是在数据库检索数据没有存进去