I have been using Emacs to access MySQL for a long time. Recently, it took more than an hour to reconfigure the environment due to a change in unit.
1. Install sudo apt-Get install in Ubuntu
Libmysqlclient-Dev and mysql-client-core-5.5
2. Download SQL. El and MySQL. El ~ /. Load the emacs file
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 "))
3. If your MySQL port is not a standard port, use the following command to set it in the. emacs file.
(Setq SQL-mysql-options (list "-P 6871 "))
4. Run the following command to set two common accounts for connecting to MySQL:
(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 ))