C++ and MySQL

darkpunkcalob

New Member
Messages
22
Reaction score
0
Points
0
So, when i try to connect to my mysql databases, i get this error:

Can't connect to MySQL server on 'darkjournal.co.cc' (111)
And sometimes this one:

Can't connect to MySQL server on 'darkjournal.co.cc' (110)
Error 110 is a timeout error, and 111 is a connection refused error... So i know it probably is not my code, but just in case:

Code:
#include <iostream>
#include <string>
#include <stdlib.h>
#include "mysql/mysql.h"

using namespace std;

MYSQL *connection, mysql;
MYSQL_RES *result;
MYSQL_ROW row;
int query_state;

int login()
{
    string usr;
    string pass;
    cout << "Username:";
    cin >> usr;
    cout << "Password:";
    cin >> pass;
    return 0;
}

int main()
{
    int garbage;
    cout << " _   _                      _   _               \n";
    cout << "( ) ( )                    ( ) ( )              \n";
    cout << "| |/'/'   _    _ _    _   _| |/'/'   _     ___  \n";
    cout << "| , <   /'_`\\ ( '_`\\ ( ) ( ) , <   /'_`\\ /' _ `\\\n";
    cout << "| |\\`\\ ( (_) )| (_) )| (_) | |\\`\\ ( (_) )| ( ) |\n";
    cout << "(_) (_)`\\___/'| ,__/'`\\__, |_) (_)`\\___/'(_) (_)\n";
    cout << "              | |    ( )_| |                    \n";
    cout << "              (_)    `\\___/'                    \n";
    cout << "________________________________________________\n\n";
    cout << "Initating mySQL...\n";
    mysql_init(&mysql);
    cout << "Connecting to Database....\n";
    connection = mysql_real_connect(&mysql,"darkjournal.co.cc","username","password","darkpunk_prototype",3306,NULL,0);
    if (connection == NULL) {
        cout << "Failed!\n\nError::\n" << mysql_error(&mysql) << endl;
        return 1;
    }
    else {
        cout << "Connection established...\n";
        login();
    }
    return 0;
}
So my question: Is there something I need to so to my account or databases to open access to my computer? Am I using the wrong port (3306 is the default port)? Or is it something else?

Please and thanks,
Darkpunk
 

gomarc

Member
Messages
516
Reaction score
18
Points
18
Hello darkpunkcalob,

Free hosting firewall blocks all in and out access to any remote connection (done mainly for security reasons). Only ‘localhost’ will work.

If you need remote access, you can try one of the paid services that x10hosting has to offer (They are great by the way)
 

callumacrae

not alex mac
Community Support
Messages
5,257
Reaction score
97
Points
48
We're a website hosting company, not database hosting!

Remote MySQL (to x10hosting, not from) has been disabled, and your code will not work. If you want remote MySQL you will have to use either Premium or VPS, although I would only recommend VPS if you are experienced in Linux administration.

~Callum
 

darkpunkcalob

New Member
Messages
22
Reaction score
0
Points
0
The databases were to hold the site content, and program was to ultimately allow access to the site for modification.

Thanks,
Darkpunk
 
Top