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

What is action and transformation in spark?

597


What are c identifiers?

629


What is difference between structure and union in c programming?

569


How would you rename a function in C?

622


void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }

1261






What are two dimensional arrays alternatively called as?

661


Why is this loop always executing once?

617


Without Computer networks, Computers will be half the use. Comment.

1877


Is c easier than java?

569


What is wrong with this program statement?

610


What are the complete rules for header file searching?

675


Is int a keyword in c?

557


How can you avoid including a header more than once?

564


What are the 5 types of organizational structures?

550


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

595