Write a C/C++ program that connects to a MySQL server and
checks intrusion attempts every 5 minutes. If an intrusion
attempt is detected beep the internal speaker to alert the
administrator. A high number of aborted connects to MySQL at
a point in time may be used as a basis of an intrusion.

Answer Posted / raghavendra

/* Simple C program that connects to MySQL Database server*/
#include <mysql.h>
#include <stdio.h>

main() {
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;

char *server = "localhost";
char *user = "root";
char *password = "PASSWORD"; /* set me first */
char *database = "mysql";

conn = mysql_init(NULL);

/* Connect to database */
if (!mysql_real_connect(conn, server,
user, password, database, 0, NULL, 0)) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}

/* send SQL query */
if (mysql_query(conn, "show tables")) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}

res = mysql_use_result(conn);

/* output table name */
printf("MySQL Tables in mysql database:\n");
while ((row = mysql_fetch_row(res)) != NULL)
printf("%s \n", row[0]);

/* close connection */
mysql_free_result(res);
mysql_close(conn);
}

Is This Answer Correct ?    17 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain how many levels deep can include files be nested?

622


Explain how do you sort filenames in a directory?

600


Can two or more operators such as and be combined in a single line of program code?

801


Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......

1738


Explain how are portions of a program disabled in demo versions?

647






What is this infamous null pointer, anyway?

605


How can you tell whether two strings are the same?

821


List some basic data types in c?

555


What are the functions to open and close the file in c language?

589


What is the difference between struct and typedef struct in c?

642


Why do we use int main instead of void main in c?

611


What is the difference between #include

and #include “header file”?

544


What is c programing language?

609


typedef struct{ char *; nodeptr next; } * nodeptr ; What does nodeptr stand for?

1066


Difference between MAC vs. IP Addressing

635