Emacs accesses MySQL

Source: Internet
Author: User

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 ))

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.