Hey everyone, I’m loving Emacs SQL mode for MySQL, but I’ve hit a snag. Our team just set up a new database on a non-standard port. I can’t figure out how to connect to it using sql-mysql. Does anyone know the trick to specify a different port number?
I’m also wondering if there’s a way to make Emacs ask for the port when connecting. It’d be super handy if it could use the default port when I don’t type anything. Is that possible?
I’ve tried looking through the documentation, but I’m not seeing anything obvious. Any help would be awesome! I really don’t want to give up using Emacs for this. Thanks in advance!
hey there! have you tried using the -P flag in sql-mysql-options? it’s pretty neat for custom ports. btw, what port are u using? I’m curious how other teams set up their dbs. maybe we could share some tips on optimizing non-standard setups? let me know if u figure it out!
I’ve encountered this issue before when working with non-standard MySQL setups. To connect to a custom port in Emacs SQL mode, you can modify the sql-mysql-options variable. Add the port option like this:
(setq sql-mysql-options '(“-P 3307”))
Replace 3307 with your actual port number. This setting goes in your Emacs configuration file.
For a more flexible approach, you can customize the sql-mysql-login-params variable to prompt for the port:
This way, Emacs will ask for the port, defaulting to 3306 if you don’t specify one. It’s quite handy for switching between different database instances.