当我在bash提示符下键入
mysql dbname时,我会自动使用我的.my.cnf文件中包含的用户名,密码和主机信息连接到数据库dbname.
解决方法
我不认为这是可能的,但您可以在模式配置中设置这样的东西:
(setq sql-connection-alist '((pool-a (sql-product 'MysqL) (sql-server "1.2.3.4") (sql-user "me") (sql-password "mypassword") (sql-database "thedb") (sql-port 3306)) (pool-b (sql-product 'MysqL) (sql-server "1.2.3.4") (sql-user "me") (sql-password "mypassword") (sql-database "thedb") (sql-port 3307)))) (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 sql-pool-a () (interactive) (sql-connect-preset 'pool-a))
有关更多信息,请查看this article.