【问题标题】:Authentication to host '127.0.0.1' for user 'root' using method 'mysql_native_password' failed with message: Unknown database 'xxx'使用方法“mysql_native_password”对用户“root”的主机“127.0.0.1”进行身份验证失败,并显示消息:未知数据库“xxx”
【发布时间】:2021-08-23 02:18:27
【问题描述】:

当我运行应用程序时,出现以下配置错误:

使用方法“mysql_native_password”对用户“root”的主机“127.0.0.1”进行身份验证失败,并显示消息:未知数据库“kubota1”

这是连接字符串:

string connectionString = "datasource=127.0.0.1;port=3306;username=root;password=;database=kubota1;";
MySqlConnection conn = new MySqlConnection(connectionString);

我已经创建了一个数据库:

【问题讨论】:

    标签: c# database connection


    【解决方案1】:

    尝试在连接字符串中指定密码值。现在,它被错过了。

    【讨论】:

      【解决方案2】:

      你能直接从 MySQL 工作台连接数据库吗? 如果是,则打开 Visual Studio > 查看 > 服务器资源管理器 > 连接到数据库。 输入所需的凭据并连接。如果它是从 Visual Studio 连接的,则从服务器资源管理器中选择数据库>>右键单击>>属性。

      您可以从那里复制连接字符串并在您的代码中使用。

      【讨论】:

        猜你喜欢
        • 2016-10-27
        • 2017-01-19
        • 2017-10-14
        • 2019-10-09
        • 1970-01-01
        • 2022-11-24
        • 1970-01-01
        • 2013-07-12
        相关资源
        最近更新 更多