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?
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
(setq sql-mysql-options (list "-P <port number>"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With