Can lsp mode be used with a mysql server. I've setup lsp for some languages but cannot succeed with mysql. So far to connect I use emacsql package with a sql-connection-alist defined.

This is what I wrote in init.el

(add-hook 'sql-mode-hook 'lsp)
(setq lsp-sqls-workspace-config-path nil)
(setq lsp-sqls-connections
    '(((driver . "mysql") (dataSourceName . "yyoncho:local@tcp(localhost:3306)/foo"))
      ((driver . "mssql") (dataSourceName . "Server=localhost;Database=sammy;User Id=yyoncho;Password=hunter2;"))
      ((driver . "postgresql") (dataSourceName . "host= port=5432 user=yyoncho password=local dbname=sammy sslmode=disable"))))

Opening a sql buffer will not start lsp. Doing


gives me

lsp--send-request-async: The connected server(s) does not support method textDocument/codeAction. To find out what capabilities support your server use ‘M-x lsp-describe-session’ and expand the capabilities section



gives me nothing

If someone can help me to setup lsp will be nice.

2 Answers 2


LSP needs a language server (independent of Emacs) running on your computer for the language.

As far as I know, there isn't one for MySQL -- and even if I'm wrong and there is one, you would have to install the language server for MySQL on your computer for lsp to use it, and configure lsp to know the name of the language server, etc.


I can see that you've copied the example config verbatim from https://emacs-lsp.github.io/lsp-mode/page/lsp-sqls/ which naturally can't work because it's specifying example databases and credentials which will unquestionably not be your databases and credentials!

The linked docs at https://github.com/lighttiger2505/sqls in turn reference the following as a description of a MySQL dataSourceName for that config:


You need to review that in the context of your own database(s) and then amend the Emacs config accordingly. (Nobody can tell you the data source for your database.)

Make sure that you end up with lsp-sqls-connections containing only genuine databases that you have access to (i.e. get rid of all the examples).

So far to connect I use emacsql package with a sql-connection-alist defined

Those lsp-sqls docs only indicate support for sql-mode. I know nothing about emacsql, but if it isn't using (or deriving from) that major mode, I don't know if it's supported. You'll want to firstly get it working for just a simple sql-mode buffer.

(In case the lsp support also requires the sql-mode buffer to be connected to a sql-interactive-mode buffer, C-uC-cTAB from sql-mode will prompt you to connect. I suspect that's not needed, but I'm only guessing.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.