1

I am developing a WINAPI C++ program in which I need users to be able to log into accounts from a website. I have never integrated MySQL into a c++ program and I am running into this issue. My MySQL is hosted with my website by dreamhost.com so the MySQL server is not on my computer but it is with dreamhost. I am not sure what I am doing wrong here but I put in this info.

    try {

    sql::Driver *driver;
    sql::Connection *con;
    sql::ConnectOptionsMap connection_properties;

    connection_properties["hostName"] = "localhost.domain.com";
    connection_properties["userName"] = "MySQLUsername";
    connection_properties["password"] = "MySQLPassword";
    connection_properties["schema"] = "database";
    connection_properties["port"] = 3306;
    connection_properties["OPT_RECONNECT"] = true;

    driver = get_driver_instance();
    con = driver->connect(connection_properties);

    delete con;

    }
        catch (sql::SQLException &e) {
        std::ostringstream os;
        os << "Error Number: " << e.getErrorCode();
        MessageBoxA(NULL, os.str().c_str(), "MySQL Error", MB_OK | 
        MB_ICONINFORMATION);
    }

It always catches error 1045. If i change the hostname it gives me 2005 or 2003 so I know it finds the host but for some reason wont access the database... Please help as this is halting my current project. The only answers I can find are for localhost servers.

I am using the username and password to PHPMyAdmin, is that correct?

  • According to Google 1045 is "access denied for user". Maybe the user account doesn't have permission to connect remotely? – Jonathan Potter Jan 23 '18 at 06:56
  • Is there a different permission between connecting remotely and connecting through phpmyadmin? @JonathanPotter – Steele Stonick Jan 23 '18 at 12:39
  • Also, it gives the same error if I put in a completely wrong username and password. But I know the info I am entering now is the correct login for PHPMyAdmin @JonathanPotter – Steele Stonick Jan 23 '18 at 15:44
  • Presumably PHPMyAdmin is installed on the same server as the database (or same subnet anyway) and so doesn't count as remote access. See e.g. https://stackoverflow.com/questions/6239131/how-to-grant-remote-access-permissions-to-mysql-server-for-user – Jonathan Potter Jan 23 '18 at 15:58

0 Answers0