Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection problems with MySql (MariaDb) #902

Open
estrusom opened this issue Mar 1, 2024 · 0 comments
Open

Connection problems with MySql (MariaDb) #902

estrusom opened this issue Mar 1, 2024 · 0 comments

Comments

@estrusom
Copy link

estrusom commented Mar 1, 2024

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();
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant