How to connect my c# application to my phpmyadmin database from my NAS?

Anonymous
2024-05-26T11:07:34.2566667+00:00

Good day, I want to try to connect to my database in my NAS.

Please take a look the image below.

nas

As you can see at the image, I want to access my database outside in my home network.

I already installed phpmyadmin in my NAS, but the problem is I don't know how to access it.

I watch a lot of tutorial videos, but no one can fix my problem.

I try it in my own and this my error.

User's image

and here my codes

//for nas db

string mysqlcon = "SERVER=192.X.X.X;" +

"PORT=3306;" +

"DATABASE=TestDB;" +

"UID=root;" +

"PASSWORD=root;";

MySqlConnection mysqlconnection = new MySqlConnection(mysqlcon);

try

{

mysqlconnection.Open();

label2.ForeColor = System.Drawing.Color.Green;

label2.Text = "Connected";

}

catch (Exception ex)

{

label2.ForeColor = System.Drawing.Color.Red;

label2.Text = ex.Message;

}

finally

{

mysqlconnection.Close();

}

the server address is my NAS ip address.

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,995 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Azizkhon Ishankhonov 435 Reputation points
    2024-05-26T15:11:29.92+00:00

    Hi

    It seems that your IP address is the local address and depending on your requirements solutions may differ.
    A. Short-term solutions, which expose your localhost to the internet:

    1. dev tunnels: https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/get-started?tabs=windows
    2. ngrok: https://ngrok.com/docs/getting-started/

    B. The Long-term solution will be to deploy your database on the server via any provider

    0 comments No comments

  2. Bruce (SqlWork.com) 66,056 Reputation points
    2024-05-26T16:57:45.0966667+00:00

    while a vpn solution is preferred. to open your database to the internet, you need to configure your router to do a incoming nat translation on a given port to the database server. see you router docs. you also need a static ipaddress from your ISP (this is usually an additional option). while you can use a what's my ipaddress to get your global ipaddress, it may not be unique but shared by other ISP users.

    0 comments No comments

  3. Olaf Helper 44,931 Reputation points
    2024-05-27T05:25:34.7866667+00:00

    I already installed phpmyadmin in my NAS

    phpmyadmin is just a tool, not a database engine.

    And it's for MySQL, not for Microsoft SQL Server; so wrong forum =>

    https://forums.mysql.com/

    0 comments No comments

  4. Anonymous
    2024-05-28T11:24:12.5333333+00:00

    Good day to all master!

    Thank you for your comments and suggestion, I finally fix this error.,

    Thank so much too the following,

    Azizkhon Ishankhonov, Bruce (SqlWork.com), Olaf Helper

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.