简体   繁体   English

C# MySql.Data.MySqlClient.MySqlException (0x80004005)

[英]C# MySql.Data.MySqlClient.MySqlException (0x80004005)

here's my connection string这是我的连接字符串

"Server=xxx.xxx.xxx.x;Database=database;Uid='root';Pwd='';"

the ip on the server is the ip of the other computer(have xampp) that I want to access.服务器上的ip是我要访问的另一台计算机(有xampp)的ip。

this is the Exception I receive.这是我收到的异常。

MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts. MySql.Data.MySqlClient.MySqlException (0x80004005):无法连接到任何指定的 MySQL 主机。 at MySql.Data.MySqlClient.NativeDriver.Open() at MySql.Data.MySqlClient.Driver.Open() at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings) at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection() at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver() at MySql.Data.MySqlClient.MySqlPool.GetConnection() at MySql.Data.MySqlClient.MySqlConnection.Open()在 MySql.Data.MySqlClient.NativeDriver.Open() 在 MySql.Data.MySqlClient.Driver.Open() 在 MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder 设置) 在 MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()在 MySql.Data.MySqlClient.MySqlPool.TryToGetDriver() 在 MySql.Data.MySqlClient.MySqlPool.GetConnection() 在 MySql.Data.MySqlClient.MySqlConnection.Open()

With mysql on C# you don't need single quote in the connexion string使用 C# 上的 mysql,您不需要在连接字符串中使用单引号

Ex :前任 :

ConnStr = "Server = XXX.XXX.XXX.XXX; Database = mydatabase; Uid = root; Pwd = yourpassword";   

MySqlConnection con = new MySqlConnection(ConnStr)

You can also verify that you can ping the other computer :您还可以验证是否可以 ping 另一台计算机:

    using System.Net.NetworkInformation;

    public static bool IsConnectedToServer()
    {
        Ping p = new Ping();
        try
        {
            PingReply reply = p.Send("XXX.XXX.XXX.XXX", 3000);
            if (reply.Status == IPStatus.Success)
                return true;
            else return false;
        }
        catch { return false; }
    }

I think your connection string is wrong我认为你的连接字符串是错误的

I should be In <appSettings> in我应该在<appSettings>

<add key="myConnectionString" value="Server=localhost;Database=dbName;User Id=username;Password=password;"/>

or或者

in <connectionStrings><connectionStrings>

<add name="myConnectionString" connectionString="Server=Server=localhost;Database=dbName;User Id=username;Password=password;" providerName="MySql.Data.MySqlClient"/>

As well as Refer this Link to Enable Remote Access for Mysql以及请参阅此链接以启用 Mysql 的远程访问

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误! mysql.data.mysqlclient.mysqlexception(0x80004005) - Error! mysql.data.mysqlclient.mysqlexception(0x80004005) MySql.Data.MySqlClient.MySqlException(0x80004005) 你的 SQL 语法有错误 - MySql.Data.MySqlClient.MySqlException(0x80004005) you have an error in your SQL syntax MySql.Data.MySqlClient.MySqlException (0x80004005):SELECT 命令拒绝用户 'XXX'@'YYY' 用于表 'bogus_table' - MySql.Data.MySqlClient.MySqlException (0x80004005): SELECT command denied to user 'XXX'@'YYY' for table 'bogus_table' 无法通过ProxySql进行过程调用,错误MySql.Data.MySqlClient.MySqlException(0x80004005):表&#39;mysql.proc&#39;不存在 - Procedure call not working via ProxySql, error MySql.Data.MySqlClient.MySqlException (0x80004005): Table 'mysql.proc' doesn't exist C#MySql.Data.MySqlClient.MySqlException错误无故 - C# MySql.Data.MySqlClient.MySqlException Error for no reason 是什么原因导致此MySql.Data.MySqlClient.MySqlException? C# - What's causing this MySql.Data.MySqlClient.MySqlException? C# MySql.Data.MySqlClient.MySqlException 超时 c# - MySql.Data.MySqlClient.MySqlException Timeout Expired c# MySQL &amp; C# MySql.Data.MySqlClient.MySqlException 在 try catch 中被捕获 - MySQL & C# MySql.Data.MySqlClient.MySqlException caught in try catch MySql.Data.MySqlClient.MySqlException:在 C# 中但在 MySQL Workbench 中工作正常 - MySql.Data.MySqlClient.MySqlException: in C# but works fine in MySQL Workbench 异常未处理,MySql.Data.MySqlClient.MySqlException - Exception Unhandled, MySql.Data.MySqlClient.MySqlException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM