+ Reply to Thread
Results 1 to 5 of 5

Thread: C++ and MySQL

  1. #1
    darkpunkcalob is offline x10Hosting Member darkpunkcalob is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    22

    C++ and MySQL

    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

  2. #2
    gomarc's Avatar
    gomarc is offline x10 Elder gomarc is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    USA
    Posts
    511

    Re: C++ and MySQL

    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)

  3. #3
    darkpunkcalob is offline x10Hosting Member darkpunkcalob is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    22

    Re: C++ and MySQL

    Thanks for the reply gomarc, saves me the worry that i was doing something wrong.

  4. #4
    callumacrae's Avatar
    callumacrae is offline not alex mac callumacrae is just really nice
    Join Date
    Dec 2007
    Location
    Wellesbourne, England
    Posts
    5,162

    Re: C++ and MySQL

    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
    I can customise your phpBB board. Send me a PM.
    lynxphp - info, tutorials and scripts
    "A forum post should be like a skirt; long enough to cover the subject but short enough to keep things interesting."

  5. #5
    darkpunkcalob is offline x10Hosting Member darkpunkcalob is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    22

    Re: C++ and MySQL

    The databases were to hold the site content, and program was to ultimately allow access to the site for modification.

    Thanks,
    Darkpunk

+ Reply to Thread

Similar Threads

  1. Replies: 1
    Last Post: 10-15-2010, 01:46 PM
  2. Replies: 2
    Last Post: 10-14-2010, 10:49 AM
  3. Replies: 2
    Last Post: 12-17-2007, 03:00 AM
  4. Replies: 2
    Last Post: 11-20-2007, 11:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers