Emacs 访问 MySQL
用Emacs访问MySQL好久了,最近因为换了单位,重新配置环境的时候居然花了一个多小时,特此记录。
1.Ubuntu下用sudo apt-get install 安装
libmysqlclient-dev 和 mysql-client-core-5.5
2.下载sql.el和mysql.el,并在~/.emacs文件中加载
http://www.emacswiki.org/emacs/sql.el
http://www.emacswiki.org/emacs/mysql.el
- (load-file (expand-file-name "/opt/emacs_plugins/sql.el"))
- (load-file (expand-file-name "/opt/emacs_plugins/mysql.el"))
- (setq sql-mysql-options (list "-P 6871"))
- (setq sql-connection-alist
- '((pool-a
- (sql-product 'mysql)
- (sql-server "ip1")
- (sql-user "user1")
- (sql-password "pwd1")
- (sql-database "db1")
- (sql-port 6871))
- (pool-b
- (sql-product 'mysql)
- (sql-server "ip2")
- (sql-user "user2")
- (sql-password "pwd2")
- (sql-database "db2")
- (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 (&rest what)))
- (sql-product-interactive sql-product)))))
- (defun mysql-a ()
- (interactive)
- (sql-connect-preset 'pool-a))
- (defun mysql-b ()
- (interactive)
- (sql-connect-preset 'pool-b))
相关推荐
CoderToy 2020-11-16
emmm00 2020-11-17
王艺强 2020-11-17
ribavnu 2020-11-16
bianruifeng 2020-11-16
wangshuangbao 2020-11-13
苏康申 2020-11-13
vivenwan 2020-11-13
moyekongling 2020-11-13
云中舞步 2020-11-12
要啥自行车一把梭 2020-11-12
aydh 2020-11-12
kuwoyinlehe 2020-11-12
minerk 2020-11-12
vitasfly 2020-11-12
jazywoo在路上 2020-11-11
敏敏张 2020-11-11
世樹 2020-11-11