-
Notifications
You must be signed in to change notification settings - Fork 63
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
Unable to connect to mysql8 database remotely with mysql_native_password plugin #169
Comments
Usually it is
|
Another thing is that you are specifying both the unix socket and IP/port. You only need one or the other and socket takes precedence. If you specify a unix socket it will look for that file locally and try to use it. Since you are saying it's on a remote machine this might be where your issue is, unless you mean to say it should appear as if it's local to you. But if this is not the case you can just remove the |
So with the following config: (= config without the socket specified) db_config = [ I get this error: So, does this mean that although IP/Port is specified it still tries to reach the local mysql.sock? |
It seems your configuration is not being applied, yes. Can you provide a more complete snippet? |
You can use this as a template: https://github.com/wojtekmach/mix_install_examples/blob/main/myxql.exs :) |
One other thing, if you are setting |
Sorry, I was working on another project. Now get back to this problem again: My application.ex:
config.exs:
|
It looks to me like you are probably using your Repos to perform the queries but your configuration is only going to the MyXQL connection you started directly under your application supervisor. If this is the case you need to add all that configuration to your Repo: https://hexdocs.pm/ecto/Ecto.html#module-repositories. Also if you only want to use your Repo you don't have to bother starting MyXQL like that. Ecto will do it automatically. |
ecto repo is configured with another database (mnesia). Additional info: I rolled back to mysql5.7. Get the same error. One detail: I made a mistake in creation of the user account and validation went wrong, this generated another error. After fixing I still get the above error about mysql.sock. So, it seems that validation of the user account has already been taken place on the remote server, then this error pops up in the console/log. |
@josevalim I have the same thoughts, but I think I did the config by the book. That is why I started this issue. |
Now with mysql5.7 I have some useful info in the server logs: Got an error reading communication packets. I'll research this first |
I'm trying to connect through a wireguard vpn tunnel on debian 11 to a debian 11 mysql8 server. The user is created with mysql_native_password plugin.
I am able to connect with heidisql via wireguard tunnel to the server with same user account.
Since I'm able to connect via heidisql, I can confirm: wireguard tunnel is working correctly, mysql8 is listening on correct socket, user is created correctly.
With MyXQL I constantly get this error:
[error] MyXQL.Connection (#PID<0.516.0>) failed to connect: ** (DBConnection.ConnectionError) (/tmp/mysql.sock) connection refused - :econnrefused
on debian 11, mysql process on the server is actually running on /var/run/mysqld/mysqld.sock. However if I specify this socket in the config, it will give me back:
[error] MyXQL.Connection (#PID<0.526.0>) failed to connect: ** (DBConnection.ConnectionError) (/var/run/mysqld/mysqld.sock) no such file or directory - :enoent
config I use:
db_config = [
name: :myxql,
hostname: "192.168.1.1", # --> endpoint IP of the VPN tunnel, MySQL8 is listening on this IP.
port: 3306,
database: "mydata",
username: "mydata_user",
pool_size: 10,
password: "blablablabla123#!"
]
additional config line for specifying socket: socket: "/var/run/mysqld/mysqld.sock"
I've spend almost 2 days on troubleshooting every single component in this setup. but after eliminating everything, I just came to the conclusion it must be something in MyXQL library or dependencies, that does not allow the remote connection.
The documentation is not really helpful in troubleshooting the above error messages. It would be handy to see where in the process something goes wrong instead of just connection refused.
The text was updated successfully, but these errors were encountered: