Unity MySQL error

Please help me! i made a save database in my unity game, but it says that there is no database date on this host. I even downloaded mysql workbench and it’s the same there. What should I do ? Here is the Unity Script:

using UnityEngine;
using MySql.Data;
using MySql.Data.MySqlClient;

public class DatabaseManager : MonoBehaviour {

  // Database connection details
  public string dbHost = "localhost";
  public string dbUser = "root";
  public string dbPass = "";
  public string dbName = "mydatabase";

  void Start() {
    // Connect to the database
    string connString = "Server=" + dbHost + ";Uid=" + dbUser + ";Password=" + dbPass + ";Database=" + dbName;
    MySqlConnection conn = new MySqlConnection(connString);
    conn.Open();

    // Query the database
    MySqlCommand cmd = conn.CreateCommand();
    cmd.CommandText = "SELECT * FROM table";
    MySqlDataReader reader = cmd.ExecuteReader();

    // Print results
    while(reader.Read()) {
      Debug.Log(reader["column"].ToString());
    }

    // Close connection
    reader.Close(); 
    conn.Close();
  }

}

database info i write in unity editor and dont say.

Hi and welcome to the forum! MySQL remote access is not available on free hosting:

8 Likes

Thank you! I will write php script and test it

Please not that you probably won’t get anywhere because of the security system:

And I think how you will be using it is disallowed. This is website hosting not database hosting. If you need free database hosting, options exist (just look them up).

7 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.