简体   繁体   English

使用C#连接到MYSQL

[英]Connection to MYSQL with c#

This is my connection class for C#, but it doesn't work: 这是我的C#连接类,但不起作用:

class DB
{
    MySqlConnection connection;
    //Baglanti adında bir bağlantı oluşturdum

    public bool baglanti_kontrol()
    {
        connection = new MySqlConnection("Server=93.89.xx.xx:3306;Database=database_database;Uid=database_userid;Pwd='password';");
        connection.Open();
        return true;
    }
}

I tried to every solution in the same topic. 我尝试了同一个主题中的所有解决方案。

My server gives permission for my IP address. 我的服务器允许我的IP地址使用。

I am getting the following exception: 我收到以下异常:

'xxxx' for user 'xx_xx' using method 'mysql_native_password' failed with message: Access denied for user 'xx_xx'@'xxxx' (using password: YES)' 使用方法'mysql_native_password'的用户'xx_xx'的'xxxx'失败,并显示以下消息:用户'xx_xx'@'xxxx'的访问被拒绝(使用密码:是)

I solve the problem like this 我这样解决问题

"Server=93.89.xx.xx;Port=3306;Database=database_database;Uid=database_userid;Pwd=password;"

Problem is I didn't define "Port" and my password like 'password' 问题是我没有定义“端口”和密码(例如“密码”)

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM