panique / huge

Simple user-authentication solution, embedded into a small framework.
2.14k stars 789 forks source link

Connection problems with MySql (MariaDb) #902

Open estrusom opened 6 months ago

estrusom commented 6 months ago

I installed a db server, MariaDb, on a Raspberry PI 4. The server works, I connect remotely using http://raspserver/adminer/?server=raspserver&username=root, this means that, The server works, port 3306 communicates, the server name is recognized, user and password are correct, I can perform selects. When I try to connect via C# I get the error "MySql.Data.MySqlClient.MySqlException: 'Host '192.168.1.158' is not allowed to connect to this MariaDB server'". The address 192.168.1.158 is not of the Raspberry server but of the PC where I am testing the program. The component installed by nuget is ADO.Net driver for MySQL for .Net Framework and .Net Core, version 8.3.0.0 and runtime v4.0.30319. Can anyone tell me why something like this happens and how to fix the problem?

Below is the code I wrote to make the connection MySqlConnectionStringBuilder conn_string = new MySqlConnectionStringBuilder(); conn_string.Server = "raspserver"; conn_string.UserID = "root"; conn_string.Password = "XXXyyyyZZZ!"; conn_string.Database = "wordpress"; conn_string.Port = 3306;

        using (MySqlConnection conn = new MySqlConnection(conn_string.ToString()))
        using (MySqlCommand cmd = conn.CreateCommand())
        {    //watch out for this SQL injection vulnerability below
            cmd.CommandText = string.Format("SELECT * FROM wp_usermeta");
            conn.Open();
            cmd.ExecuteNonQuery();
        }