A
A
alinaparamonova12021-07-18 13:35:34
MySQL
alinaparamonova1, 2021-07-18 13:35:34

Why can't connect to MySql database?

Hey!
I'm trying to connect to the database, but I'm getting the following error -
60f4031fdaf9d159669943.png
and the same error is also displayed in this line
*****
adapter.Fill(table);
*****

private void connecting_Click(object sender, EventArgs e)
        {
            string userLogin = userName.Text;
            string pass= Pass.Text;
            int hash = Convert.ToInt32(Hash.Text);

            baseUsers db = new baseUsers();
            DataTable table = new DataTable();
            MySqlDataAdapter adapter = new MySqlDataAdapter();
            MySqlCommand command = new MySqlCommand("SELECT * FROM `users` WHERE 'name' = @uL AND 'pass' = @uK AND 'hash' = @uH", db.GetConnection());

            command.Parameters.Add("uL", MySqlDbType.VarChar).Value = userLogin;
            command.Parameters.Add("uK", MySqlDbType.VarChar).Value = pass;
            command.Parameters.Add("uH", MySqlDbType.Int32).Value = hash;

            adapter.SelectCommand = command;
            adapter.Fill(table);

            if (table.Rows.Count > 0)
            {
                MessageBox.Show("user [true]", "INFO");
            }
            else
            {
                MessageBox.Show("user [false]", "INFO");
            }

        }

I ask for help, I'm connecting to a remote server, here is the data (perhaps not correct)

static string user = "server=77.222.40.101;port=5431;username=users;password=USER00;database=userBase";

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2021-07-18
@sarapinit

Try to connect through MySql Workbench first,
or check access with the powershell command
Test-NetConnection 77.222.40.101 -Port 5431
. If the connection fails, then the hosting most likely has a firewall that blocks access from unfamiliar IPs. This is useful if you're leaking all connection data to the network, as you've done now.
(Do not do this in the future and change the password)
If there is a firewall, then you need to add your public IP to the exceptions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question