How to use the option skip-name-resolve when using MySQLdb for Python?

CreeTar picture CreeTar · Jul 12, 2011 · Viewed 59.1k times · Source

I try to connect to database in a domain from my virtual machine. It works on XP, but somehow does not work on Win7 and quitting with: "OperationalError: (1042, "Can't get hostname for your address")"

Now I tried disable Firewall and stuff, but that doesn't matter anyway. I don't need the DNS resolving, which will only slow everything down. So I want to use the option "skip-name-resolve", but there is no my.ini or my.cnf when using MySQLdb for Python, so how can I still use this option?

Thanks for your help -Alex

Answer

Ranzit picture Ranzit · Apr 3, 2013

Add the following line(skip-name-resolve) in the /etc/mysql/my.cnf file

[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-locking
skip-name-resolve

And restart the mysql server