Emacs how to use ssh tunnel to connect to remote MySQL

前端 未结 3 658
感动是毒
感动是毒 2021-02-06 12:18

I have a bunch of remote MySQL servers, that allow connection only from localhost. To connect to them I do the following:

ssh host
mysql -uuser -psecret -hhost.m         


        
3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-06 12:41

    As of Emacs 25.1 there is a new sql-default-directory option in the sql-connection-alist. Setting this for each server that needs it allows you to use the backend program from any given server without any defadvice or product-specific tricks. Just the setting to your the connection like:

    (sql-default-directory "/host.myhost.com:")
    

    Or, if you need to specify ssh for some reason:

    (sql-default-directory "/ssh:host.myhost.com:")
    

提交回复
热议问题