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

#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 ?    5 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is meant by keywords in c?

835


What is pre-emptive data structure and explain it with example?

3468


What is advantage of pointer in c?

906


Are there namespaces in c?

782


Is c programming hard?

769


What is c language in simple words?

808


C program to find all possible outcomes of a dice?

2059


Explain pointers in c programming?

851


Explain how can I open a file so that other programs can update it at the same time?

859


What is void main ()?

800


Write a C Program That Will Count The Number Of Even And Odd Integers In A Set using while loop

1911


What is sizeof int in c?

814


How can I read data from data files with particular formats?

810


Explain how can I write functions that take a variable number of arguments?

796


What is c value paradox explain?

786