title: Emacs how to use ssh tunnel to connect to remote MySQL
body: <p>I have a bunch of remote MySQL servers, that allow connection only from localhost. To connect to them I do the following:</p>
  
  <pre><code>ssh host
  mysql -uuser -psecret -hhost.myhost.com
  </code></pre>
  
  <p>In emacs I configured the connection to local MySQL, using sql-mysql-mode:</p>
  
  <pre><code>(setq sql-connection-alist
        '((pool-a
           (sql-product 'mysql)
           (sql-server "localhost")
           (sql-user "user")
           (sql-password "secret")
           (sql-database "")
           (sql-port 3306))
          ))
  
  (defun sql-connect-preset (name)
    "Connect to a predefined SQL connection listed in `sql-connection-alist'"
    (eval `(let ,(cdr (assoc name sql-connection-alist))
      (flet ((sql-get-login (&amp;rest what)))
        (sql-product-interactive sql-product)))))
  
  (defun sql-local ()
    "Connect to the local MySQL server"
    (interactive)
    (sql-connect-preset 'pool-a)
    (delete-other-windows))
  
  (define-key global-map [f10] 'sql-local)
  </code></pre>
  
  <p>So, every time I click <code>F10</code>, I get MySQL shell.</p>
  
  <p>Is it possible to tune sql-mysql, so it connected to external machine via ssh and used mysql program on that machine, so I could connect from Emacs to everywhere?</p>