kndndrj / nvim-dbee

Interactive database client for neovim
GNU General Public License v3.0
710 stars 48 forks source link

Cannot connect to MySQL #14

Closed artfulrobot closed 1 year ago

artfulrobot commented 1 year ago

Excited to try this, but on entering my mysql connection details I get

[init]: function Dbee_register_connection[1]..remote#define#request, line 2: Vim(let):Unable to connect to database: default addr for network '127.0.0.1:13306' unknown

My config:

{
  "kndndrj/nvim-dbee",
  dependencies = { "MunifTanjim/nui.nvim", },
  build = function()
    require("dbee").install()
  end,
  config = function()
    require("dbee").setup({
      connections = {
        {
          name = "Something",
          type = "mysql",
          url = "mysql://root:secret@127.0.0.1:13306/my_database",
        }
      }
    })
  end,
},

The credentials, the port are correct and work from the command line with the standard mysql client.I've tried localhost and 0.0.0.0 too.

Could this be a bug? Or am I doing something wrong?

kndndrj commented 1 year ago

Hey, I'm not sure if url is correct or not, but can you please refer to mysql go driver's readme and check if they use some sort of special naming? https://github.com/go-sql-driver/mysql#dsn-data-source-name

Please try it and let me know if it helped :)

artfulrobot commented 1 year ago

@kndndrj Ah, ok, great, thank you :heart:

So the correct format for MySQL seems to be (for my non-standard 13306 port):

{
  name = "whatever - refers to the connection, not the database",
  type = "mysql",
  ulr = "user:pass@tcp(0.0.0.0:13306)/mydbname"
}

Things that are unusual about the url field compared to other DSNs:

The other thing that's noticable - may be a separate issue? - is that once you're 'in', the drawer shows:

(connection name) » structure » all databases

and allows you to toggle-open any database. But then you can't look at any tables in those databases because it says they don't exist in mydbname specified in the connection. It seems odd to show stuff that can't be accessed and it would be cleaner to show the selected/filtered/limited mydbname as selected/opened somehow.

Anyway, thanks, I'm set up now and will continue testing.

weirdan commented 1 year ago

url = "user:pass@tcp(0.0.0.0:13306)/mydbname"

This doesn't seem to work anymore. The client now attempts to parse it as an actual URL, and it's not a valid url:

https://github.com/kndndrj/nvim-dbee/blame/09a15121eb26a9845c5a961beb2a17285a5d1eee/dbee/clients/mysql.go#L28