[英]C#: MySQL Exception was unhandled
An unhandled exception of type MySql.Data.MySqlClient.MySqlException
occurred in MySql.Data.dll
MySql.Data.MySqlClient.MySqlException
发生了MySql.Data.dll
类型的未处理的异常
Additional information: 附加信息:
Access denied for user 'groupdes_ling'@'60.50.32.226' (using password: YES)
This error occurs whenever i'm trying to run my program. 每当我尝试运行程序时,都会发生此错误。 The coding is pasted below:
编码粘贴在下面:
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 GroupDesignProject
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
string MyConnectionString = "Server=31.220.105.189;Database=groupdes_GDP;Uid=groupdes_ling;Pwd=0164851286;";
MySqlConnection connection = new MySqlConnection(MyConnectionString);//create connection
MySqlCommand cmd;
connection.Open();//connect to database
//write INSERT command and execute
cmd = connection.CreateCommand();//create command
cmd.CommandText = "INSERT INTO trial (Name)values ('" + textBox1.Text + "');";
cmd.ExecuteNonQuery();
//disconnect from database
if (connection.State == ConnectionState.Open)
{
connection.Close();
}
}
}
} }
I still can't manage to solve this error. 我仍然无法解决这个错误。 Thanks for the help
谢谢您的帮助
You need to add permissions for that user/host/password combination to the MySQL instance. 您需要将该用户/主机/密码组合的权限添加到MySQL实例。 For example;
例如;
GRANT ALL ON *.* to 'groupdes_ling'@'60.50.32.226' IDENTIFIED BY 'Password';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.