title: Is it possible to use Mysql with SqlAlchemy and Flask if my mysql socket isn't in /tmp?
body: <p>The location for mysql.sock on my system is <strong>/usr/local/mysql5/mysqld.sock</strong></p>
  
  <pre><code>thrilllap-2:tmp reuven$ mysqld --print-defaults
  mysqld would have been started with the following arguments:
  --socket=/usr/local/mysql5/mysqld.sock --port=3306 
  </code></pre>
  
  <p>When I try to use mysql via sqlalchemy from flask, I get:</p>
  
  <pre><code>  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
  </code></pre>
  
  <p>The mysql program connects correctly to the database, as does every other mysql client on my system.</p>
  
  <p>My my.cnf has the correct location for the socket</p>
  
  <pre><code>[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
  </code></pre>
  
  <p>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</p>
  
  <p><a href="http://packages.python.org/Flask-SQLAlchemy/config.html" rel="noreferrer">http://packages.python.org/Flask-SQLAlchemy/config.html</a></p>
  
  <p>My questions:</p>
  
  <ol>
  <li>Where does sqlalchemy get the idea that /tmp/mysql.sock is the correct location?</li>
  <li>Is there a way to change the default via the Flash-SQLAlchemy connector</li>
  </ol>