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 / ruth

/* 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 ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Difference between Shallow copy and Deep copy?

1572


What is the difference between the = symbol and == symbol?

630


What are the benefits of organizational structure?

575


Explain what are multibyte characters?

629


What is a volatile keyword in c?

638






Explain main function in c?

630


What are the different types of C instructions?

679


What is a lvalue

664


What is formal argument?

652


What is the difference between struct and union in C?

575


How to explain the final year project as a fresher please answer with sample project

472


In c programming typeing to occupy the variables in memory space. if not useing the variable the memory space is wasted.ok, how to avoid the situation..? (the variable is used & notused)

1634


What is the ANSI C Standard?

780


Synonymous with pointer array a) character array b) ragged array c) multiple array d) none

618


How can I trap or ignore keyboard interrupts like control-c?

620