Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8792053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:55:36+00:00 2026-06-13T22:55:36+00:00

I am writing a c++ program that will store everything in a mysql database.

  • 0

I am writing a c++ program that will store everything in a mysql database. I would like to avoid the Windows Security window from popping up and asking if mysqld can have priviledges. If I click cancel (in response to the firewall window), the program still runs just fine because everything is local.

I am trying to use named pipes with the –skip-networking flag to avoid this firewall window.

START EDIT:

I am using a portable version of mysqld. It won’t have admin priviledges. (Thanks to Ben for pointing out that this is an important piece of information)

END EDIT

I am using the following command to start the mysqld server:

C:\tmp_report\12345\mysqld\mysql\bin\mysqld --user=root \
--basedir="C:\tmp_report\12345\mysqld\\mysql" \
--datadir="C:\tmp_report\12345\mysqld\data" \
--pid-file="C:\tmp_report\12345\mysqld\mysql.pid" \
--log-error="C:\tmp_report\12345\mysqld\mysql.err" \
--skip-networking \
--enable-named-pipe

This works and I am able to connect to the database using the following command line statement:

mysql --pipe -uroot 

I am trying to connect through the c-api as follows:

unsigned int mysql_timeout=200;
unsigned int protocol=MYSQL_PROTOCOL_PIPE;
bool mysql_reconnect=true;
bool mysql_local_infile=true;

if (mysql_options(conn,MYSQL_OPT_CONNECT_TIMEOUT, (char *)&mysql_timeout)){*logstream<<"mysql option error connect_timeout";}

if (mysql_options(conn,MYSQL_OPT_READ_TIMEOUT, (char *)&mysql_timeout)){*logstream<<"mysql option error read_timeout";}

if (mysql_options(conn,MYSQL_OPT_WRITE_TIMEOUT, (char *)&mysql_timeout)){*logstream<<"mysql option error write_timeout";}

if (mysql_options(conn,MYSQL_OPT_RECONNECT,                   &mysql_reconnect)){*logstream<<"mysql option error reconnect";}

if (mysql_options(conn,MYSQL_OPT_LOCAL_INFILE,                &mysql_local_infile)){*logstream <<"mysql option error local_infile";}

if (mysql_options(conn,MYSQL_OPT_NAMED_PIPE,                  NULL)){*logstream<<"mysql option error MYSQL_OPT_NAMED_PIPE";}
if (mysql_options(conn,MYSQL_OPT_PROTOCOL,            (char *)&protocol))          {*logstream<<"mysql option error protocol";}

if (!mysql_real_connect(conn,
        "localhost", // SERVER
        "root",      // USER
        NULL,   // PASS
        NULL,   // DATABASE
        0,    // port
        NULL, // socket
        0     // client_flag
    )){
    *logstream<<"Database::connect mysql_real_connect failed"<<endl;
    *logstream<<mysql_error(conn)<<endl;
    conn=NULL;
}

The result of this mysql_real_connect call is:

Database::connect mysql_real_connect failed
Lost connection to MySQL server at 'waiting for initial communication packet', system error: 0

If I use the TCPIP connection, everything works fine except that the Windows firewall pops up. I would really like to make this work without requiring the user to click cancel on the firewall window.

Any help is greatly appriciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:55:37+00:00Added an answer on June 13, 2026 at 10:55 pm

    If MySQL is intentionally local only, you should simply configure it to listen only on the local address. Put this in your my.cnf file:

    bind-address     = 127.0.0.1
    

    Otherwise use netsh advfirewall or similar to configure the firewall to allow MySQL. This would generally be done when you install MySQL.

    Examples:

    • http://support.microsoft.com/kb/947709

    Or from script:

    • http://technet.microsoft.com/en-us/library/cc737845(v=WS.10).aspx

    For a single-use installation which doesn’t have or require admin privileges, you can configure local communication using the nonroutable IP address and a random port.

    You can achieve this by adding --bind-address=127.0.0.1 --port=62190 to the command line.

    You won’t be able to alter the firewall rules unless you are an administrator, and listening on named pipes generally requires administrative privileges too. Creating a shared memory section requires SeCreateGlobalPrivilege, so essentially the same restriction applies.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my situation. I am writing a program that will store a database.
I'm writing a program in C# that will need to store a few Data
I am writing a program that will query an MS access database, return the
I'm writing an application that is using a database (currently MySQL 4) to store
I am contemplating writing a program that will move some newly created dirs to
I'm a writing a program that will determine the number of lines, characters, and
I'm writing a program that sends an array through a function (upperhess) that will
I'm writing a simple program that will run entirely client-side. (Desktop programming? do people
I am writing an HTML program that will be accessed by over 500 people
I am writing a program, for homework, that will add 2 8-bit binary numbers.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.