Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect to MySQL #14

Closed
artfulrobot opened this issue May 19, 2023 · 3 comments
Closed

Cannot connect to MySQL #14

artfulrobot opened this issue May 19, 2023 · 3 comments

Comments

@artfulrobot
Copy link

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
Copy link
Owner

kndndrj commented May 19, 2023

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
Copy link
Author

artfulrobot commented May 20, 2023

@kndndrj Ah, ok, great, thank you ❤️

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:

  • there's no mysql:// at the start
  • you need tcp(...) wrapping the address field. I think (untested) you'd need unix(...) for a socket.

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
Copy link

weirdan commented Aug 17, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants