Monday 15 September 2014

sql mode - Emacs how to use ssh tunnel to connect to remote MySQL -


I have a bunch of remote MySQL servers, which allows connections only from local hosts, I have configured the connections in the local MySQL, sql-sql-sql- Using mysql-mode:

  (setq sql-connection-alist '(pool-A (SQL-product' mysql) (SQL-server "localhost") (SQL) (SQL) -Password "spy") (SQL- Password "secret") (SQL-Database "") (SQL-Port 3306)) (defun sql-connect-preset (name) "Connect to a predefined SQL connection 'Sql-connection-alist' (Cd, (Sdor name sql-connection-ulst)) (flat (sql-log-in-login (and what else is)) (SQL-product-interactive SQL-product))))) (defun sql-local () "Connect to local MySQL server" (interactive) (SQL-Connect-Preset 'Pool-A) (Delete-Other-windows )) (Define-Key Global Map [F10] 'sql-local)   

So, every time I click on F10 , open MySQL get.

Is it possible to tune Sune-mysql, so it is connected to an external machine via SS and that machine uses the mysql program, so I could connect with Emacs every For the place?

Uses SQL mode default-directory when it is installed The connection to the database, so if the variable is in TRAMP format, then you can do something like that to ssh (or whatever) will be used to connect to the remote host first, then use the database client locally

  (defadvice sql-mysql (active around sql-mysql) "SSH in linux, then connect" (two (default-free) You can definitely change  "/ ssh: host.myhost." / Ssh: Host.myhost.com: ") ad-do-it))   

Com: " with a function call that will ask you to connect to the host, and so on.

No comments:

Post a Comment