使用C#代码的用户拒绝远程MySql访问,但可以与DbVisualizer连接

编程入门 行业动态 更新时间:2024-10-24 13:18:35
本文介绍了使用C#代码的用户拒绝远程MySql访问,但可以与DbVisualizer连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我可以在C#/.Net Winform应用程序中连接到本地MySql服务器,但是当我尝试连接到远程MySql服务器时.我收到拒绝用户@'%'访问数据库"错误消息.但是,如果远程服务器拒绝连接.如何使用DbVisualizer连接到远程MySql数据库?我很确定问题不在于代码,而在于服务器设置.

I can connect to local MySql server in my C#/.Net winform app but when I try to connect to a remote MySql server. I got a "Access denied for user @'%' to database" error message. However, if the remote server is denying the connection. How come I can connect to the remote MySql database with DbVisualizer? I'm pretty sure the problem is not with code but rather the server settings.

推荐答案

将此代码与您的代码进行比较.

compare this code with yours.

private void button1_Click(object sender, System.EventArgs e) { string MyConString = "SERVER=localhost;" + "DATABASE=mydatabase;" + "UID=testuser;" + "PASSWORD=testpassword;"; MySqlConnection connection = new MySqlConnection(MyConString); MySqlCommand command = connection.CreateCommand(); MySqlDataReader Reader; command.CommandText = "select * from mycustomers"; connection.Open(); Reader = command.ExecuteReader(); while (Reader.Read()) { string thisrow = ""; for (int i= 0;i<Reader.FieldCount;i++) thisrow+=Reader.GetValue(i).ToString() + ","; listBox1.Items.Add(thisrow); } connection.Close(); }

更多推荐

使用C#代码的用户拒绝远程MySql访问,但可以与DbVisualizer连接

本文发布于:2023-11-09 22:56:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573661.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:代码   用户   DbVisualizer   MySql

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!