Specify a Port Number in Emacs sql-mysql

Question :

Specify a Port Number in Emacs sql-mysql,

Answer :

I’ve been using Emacs’s sql interactive mode to talk to the MySQL db server and gotten to enjoy it. A developer has set up another db on a new non-default port number but I don’t know how to access it using sql-mysql.

How do I specify a port number when I’m trying to connect to a database?

It would be even better if Emacs can prompt me for a port number and just use the default if I don’t specify. Any chances of that?

Read More  Hidden Features of C#?

,

After digging through the sql.el file, I found a variable that allows me to specify a port when I try to create a connection.

This option was added GNU Emacs 24.1.

sql-mysql-login-params

List of login parameters needed to connect to MySQL.

I added this to my Emacs init file:

(setq sql-mysql-login-params (append sql-mysql-login-params '(port)))  

The default port is 0. If you’d like to set that to the default MySQL port you can customize sql-port

(setq sql-port 3306) ;; default MySQL port  

There is a sql-*-login-params variable for all the popular RDMS systems in GNU Emacs 24.1. sql-port is used for both MySQL and PostreSQL

Read More  Replicating load related crashes in non-production environments

That’s the answer Specify a Port Number in Emacs sql-mysql, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you