The location for mysql.sock on my system is /usr/local/mysql5/mysqld.sock
thrilllap-2:tmp reuven$ mysqld --print-defaults
mysqld would have been started with the following arguments:
--socket=/usr/local/mysql5/mysqld.sock --port=3306
When I try to use mysql via sqlalchemy from flask, I get:
File "build/bdist.macosx-10.6-intel/egg/MySQLdb/connections.py", line 187, in __init__
sqlalchemy.exc.OperationalError: (OperationalError) (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)") None None
The mysql program connects correctly to the database, as does every other mysql client on my system.
My my.cnf has the correct location for the socket
[client]
port = 3306
socket = /usr/local/mysql5/mysqld.sock
[safe_mysqld]
socket = /usr/local/mysql5/mysqld.sock
[mysqld_safe]
socket = /usr/local/mysql5/mysqld.sock
[mysqld]
socket = /usr/local/mysql5/mysqld.sock
port = 3306
The base "SQLAlchemy" library has an option where you can specify the location of the mysql.sock, but this isn't exposed through the sqlalchemy / flask library
http://packages.python.org/Flask-SQLAlchemy/config.html
My questions:
- Where does sqlalchemy get the idea that /tmp/mysql.sock is the correct location?
- Is there a way to change the default via the Flash-SQLAlchemy connector
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…