使用localhost和127.0.0.1都无法连接mysql
2015-03-22 23:16
477 查看
如果这个时候使用用主机名和::1能够连接的话,那可以确定是被ipv6坑了
因为IPv6协议将localhost和127.0.0.1都映射为::1
这个时候需要按照ipv6的地址进行连接
具体应看下面的说明:
by Ashwani
Kumar - Oct 10th, 2012 - posted in Technical | Tagged
as ipv6, mysql | Comments
If you are one of those who does not know that there is a new way to connect to MySQL database with an IPV6 IP address, then keep reading. We will see how to connect to a mysql database on a server with an IPv6 address.
I struggled for this, so I wanted to document it. Source: Wiki
IPv6
IPv6 addresses have two logical parts: a 64-bit network prefix, and a 64-bit host address part.
(The host address is often automatically generated from the interface MAC address.) An IPv6 address is represented by 8 groups of 16-bit hexadecimal values separated by colons (:) shown as follows:
A typical example of an IPv6 address is:
The hexadecimal digits are case-insensitive.
This new approach is no where documented over the internet, and a bug has been filed by Mark Mathews to include this as documentation in next release of MYSQL JDBC connector. Thanks to Mark for Pointing this out to us.
因为IPv6协议将localhost和127.0.0.1都映射为::1
这个时候需要按照ipv6的地址进行连接
具体应看下面的说明:
Connecting To My Sql Server Using An Ipv6 Address
by AshwaniKumar - Oct 10th, 2012 - posted in Technical | Tagged
as ipv6, mysql | Comments
If you are one of those who does not know that there is a new way to connect to MySQL database with an IPV6 IP address, then keep reading. We will see how to connect to a mysql database on a server with an IPv6 address.
I struggled for this, so I wanted to document it. Source: Wiki
IPv6
Address Format
IPv6 addresses have two logical parts: a 64-bit network prefix, and a 64-bit host address part.(The host address is often automatically generated from the interface MAC address.) An IPv6 address is represented by 8 groups of 16-bit hexadecimal values separated by colons (:) shown as follows:
A typical example of an IPv6 address is:
2001:0db8:85a3:0000:0000:8a2e:0370:7334.
The hexadecimal digits are case-insensitive.
Method to connect to MYSQL using an IPv4 address (traditional way)
1 2 3 4 | urlString = “jdbc:mysql://10.144.1.216:3306/dbName”; Class.forName(driver); DriverManager.setLoginTimeout(getConnectionTimeOut()); dbConnection = DriverManager.getConnection(urlString,user,password); |
Method to connect to MYSQL using an IPv6 address (New way)
1 2 3 4 | urlString = “jdbc:mysql://address=(protocol=tcp)(host=fe80::5ed6:baff:fe14:a23e)(port=3306)/db”; Class.forName(driver); DriverManager.setLoginTimeout(getConnectionTimeOut()); dbConnection = DriverManager.getConnection(urlString,user,password); |
相关文章推荐
- Mac os 解决无法使用localhost连接mysql问题
- 使用 localhost 无法连接 MySQL 数据库的解决方案
- mysql能用localhost连接不能使用127.0.0.1连接的问题之一
- Mac os 解决无法使用localhost连接mysql问题
- php程序连接mysql只能使用localhost,不能使用127.0.0.1
- mysql能用localhost连接不能使用127.0.0.1连接的解决办法
- MySQL可以用localhost连接,使用IP地址无法连接问题
- mysql能用localhost连接不能使用127.0.0.1连接的解决办法
- 使用localhost和127.0.0.1连接mysql的区别
- centos下mysql无法通过localhost连接却可以通过127.0.0.1连接的问题
- MYSQL - php 使用 localhost 无法连接数据库
- MySQL : 报错:1130-host ... is not allowed to connect to this MySql server 开放mysql远程连接 不使用localhost
- 连接MYSQL时,主机名为 localhost 和 127.0.0.1 的区别
- 使用SVCUTIL生成客户端代理类时:元数据包含无法解析的引用:“https: 无法为 SSL/TLS 安全通道与颁发机构“localhost”建立信任关系。基础连接已经关闭: 未能为 SSL/TL
- 报错:1130-host ... is not allowed to connect to this MySql server 开放mysql远程连接 不使用localhost
- 解决sqlserver使用IP无法连接的问题,用localhost或者‘“.”可以连接
- 连接MYSQL时,主机名为 localhost 和 127.0.0.1 的区别
- mysql localhost与127.0.0.1以及ip连接的区别
- 报错:1130-host ... is not allowed to connect to this MySql server 开放mysql远程连接 不使用localhost
- 报错:1130-host ... is not allowed to connect to this MySql server 开放mysql远程连接 不使用localhost