Weird MySQL Python mod_wsgi Unable to connect to MySQL server in "localhost" problem (49)

StackOverflow had similar questions about this, but I did not find the same situation. This is on an OS X Leopard computer using MySQL

Some initial information:

MySQL Server version        5.1.30
Apache/2.2.13 (Unix)
Python 2.5.1
mod_wsgi 3

mysqladmin also has skip-networking specified as OFF

I can connect to mysql from python command line. But when I try to do this through mod_wsgi, using code that is copied and pasted or through Django, I get a general rejection

OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (49)")

I looked at the mysql manual and tried its troubleshooting tips, for example

telnet localhost 3306

and i do get a connection.

I may not try to connect as root.

, ? !

+5
4

, - SELinux./usr/bin/httpd 3306.

setsebool httpd_can_network_connect_db on

, , SELinux. Avinash Meetoo , :

setsebool -P httpd_can_network_connect_db

selinux .

+11

Django:

OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (49)")

, mysql 3306 django.

+1

. , :

DATABASE_HOST = 'localhost' 127.0.0.1

/ my.ini:

bind-address 127.0.0.1

.

0

, telnet-. , :

shell> perror 49
OS error code  49:  Can't assign requested address

localhost, , IPv4-. , , , IPv6.

shell> ifconfig lo0

, Apache/mod_wsgi/etc..

import python
print socket.gethostbyname('localhost')
print socket.gethostbyaddr('127.0.0.1')

, (-, Django), UNIX Socket Django, , ( ):

DATABASE_HOST = '/tmp/mysql.sock'

.

, MySQL, - , , IP- .

Hope this helps a bit.

0
source

All Articles