_Hehehe... lots of issues recently. Here is one more for you_
For some reason, mysql 8 conection expects a domain name and it isn't possible to connect with 127.0.0.1:
export DATABASE_URL='mysql://FOO:[email protected]:3306/BAZ'
... error occurred while attempting to establish a TLS connection: InvalidDNSNameError
The same issue goes away when using localhost
a dns failure for localhost sounds like a system configuration problem, I often see it on fresh linux machines that don't have it setup in /etc/hosts
I completely misread that. Anyway.. heh. The solution is simple.
mysql://FOO:BAR@[127.0.0.1]:3306/BAZ
That's the standard syntax for using IPs in URLs.
Hum... That is strange. Now a new error arises:
error with configuration: invalid IPv6 address
This InvalidDNSNameError behavior only happens with MySQL 8. 127.0.0.1 works fine for PostgreSQL and MariaDB
I'm having the same issue with using an IP address for connecting also.
MySqlPool::connect("mysql://user:[email protected]:3306/schema")?;
Error:
0: error occurred while attempting to establish a TLS connection: InvalidDNSNameError
1: InvalidDNSNameError
I was not aware of the square brackets being standard syntax, I've not seen that in my life - it doesn't seem very standard lol.
I switched to square brackets and now receive this error:
MySqlPool::connect("mysql://user:pass@[192.168.0.21]:3306/schema")?;
The application panicked (crashed).
Message: URL ParseError { invalid IPv6 address }
Location: C:\Users\User Name\.cargo\registry\src\github.com-1ecc6299db9ec823\mysql-20.1.0\src\conn\opts.rs:960
The bottom issue is caused by the mysql-20.1 crate. If I use the mysql-20.1 crate directly I receive the same error.
However, the square brackets are not required by the mysql-20.1 crate, so that seems to be an SQLx exclusive
You can use this tool to convert your IPv4 to an IPv6 address: Convert IPv4 to IPv6
As an example, use mysql://FOO:BAR@[0:0:0:0:0:ffff:7f00:1]:3306/BAZ rather than mysql://FOO:[email protected]:3306/BAZ for your DATABASE_URL.
Got error: invalid IPv6 address with the suggested url format: mysql://FOO:BAR@[ip-address]:3306/BAZ.
And converting the ip-address to ipv6 leads to another error: error: error communicating with the server: failed to lookup address information: nodename nor servname provided, or not known
Well, the cause turns out to be rustls(webpki underneath)'s lack support of ipaddress; In Cargo.toml, just change "runtime-tokio-rustls" to "runtime-tokio-native-tls"(i use tokio, e.g.), the issue should be gone.
NOTE there seems no need to wrap ipaddress inside brackets: mysql://FOO:BAR@[ipaddress]:3306/BAZ -> mysql://FOO:BAR@ipaddress:3306/BAZ
Most helpful comment
I completely misread that. Anyway.. heh. The solution is simple.
That's the standard syntax for using IPs in URLs.