我正在尝试连接到我的MySQL数据库,我可以通过localhost
进行此操作。这工作正常,并且连接成功。但是,当我尝试使用公共IP连接时,它无法登录。能够与公共IP连接至关重要。
到目前为止,我有:
bind-address=127.0.0.1
/ bind-address=::1
更改为
bind-address=0.0.0.0
/ bind-address=::
一切都在Windows 10上运行,并且WAMP托管一切。
C#代码:
private void Loginbutton_Click(object sender, EventArgs e)
{
String username = user.Text;
String password = pass.Text;
String server = serverAddress.Text;
int port = 3306;
String database = "poppy";
String connectionString = String.Format("server={0};port={1};user id={2}; password={3}; database={4}", server, port, username, password, database);
MySqlConnection connection = new MySqlConnection(connectionString);
try
{
connection.Open();
MessageBox.Show("successful connection");
connection.Close();
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message + connectionString);
}
}
错误: