我想連接到我的服務器上的MySQL數據庫。下面是我使用的連接我的小樣本:無法連接到遠程MySQL數據庫
using System;
using System.Data;
using MySql.Data.MySqlClient;
namespace MySqlTest
{
class MainClass
{
public static void Main (string[] args)
{
string connectionString =
"Server=12.34.546.213;" +
"Database=Test;" +
"UID=root;" +
"Password=password;";
IDbConnection dbcon;
dbcon = new MySqlConnection(connectionString);
dbcon.Open();
我收到以下錯誤,當我嘗試執行此代碼:
Unhandled Exception: MySql.Data.MySqlClient.MySqlException: Access denied for us er 'root'@'12.34.546.213' (using password: YES) at MySql.Data.MySqlClient.MySqlStream.ReadPacket() at MySql.Data.MySqlClient.NativeDriver.AuthenticateNew() at MySql.Data.MySqlClient.NativeDriver.Authenticate() at MySql.Data.MySqlClient.NativeDriver.Open() at MySql.Data.MySqlClient.Driver.Open() at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings ) at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection() at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection() at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver() at MySql.Data.MySqlClient.MySqlPool.GetConnection() at MySql.Data.MySqlClient.MySqlConnection.Open() at MySqlTest.MainClass.Main(String[] args) in c:\Users\dvargo\Documents\Proje cts\MySqlTest\MySqlTest\Main.cs:line 18 Press any key to continue . . .
任何想法,這可能是爲什麼?我如何給root權限以便我可以訪問它?
您是否允許使用MYSQL實例上的root帳戶進行遠程訪問? –
在my.cnf文件中,我更改了'#bind-address = 123.34.567.89'這是我的服務器的IP地址。除此之外,我還需要做些什麼? – user489041