问题描述
我有两台笔记本电脑运行Windows:
A与IP:192.168.109.100和B:192.168.109.101
我尝试连接B中的数据库mysql存储从A使用C#。
我已经添加到文件my.ini行bind-address = 192.168.109.101之后[mysql]
这是我的代码:
I have two laptop run Windows:
A with IP:192.168.109.100 and B:192.168.109.101
I try to connect database mysql store in B from A using C#.
I have added to file my.ini line "bind-address = 192.168.109.101" after [mysql]
Here is my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btn_connect_Click(object sender, EventArgs e)
{
try
{
string constring = "Server=192.168.109.101;Database=luan_van;Port=3306;User ID=root;Password=";
MySqlConnection conDataBase = new MySqlConnection(constring);
MySqlDataAdapter myData = new MySqlDataAdapter();
myData.SelectCommand = new MySqlCommand("select * from tt_nhanvien;", conDataBase);
MySqlCommandBuilder cb = new MySqlCommandBuilder(myData);
conDataBase.Open();
MessageBox.Show("Connect");
conDataBase.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
错误用户'root验证主机'192.168.109.101' '使用方法'mysql_native_password'失败并显示消息:用户'root @ Administrator'拒绝访问(使用密码:否)
如何解决?
It's error "Authentication to host '192.168.109.101' for user 'root' using method 'mysql_native_password' failed with message: Access denied for user 'root@Administrator' (using password:NO)"
How can i fix it?
推荐答案
这篇关于如何使用C#连接远程数据库mysql?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!