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 pointer to pointer in c with example?

544


What is ponter?

768


Explain the difference between exit() and _exit() function?

632


Is c is a high level language?

616


What is struct node in c?

612






A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler

622


The file stdio.h, what does it contain?

663


How can I open files mentioned on the command line, and parse option flags?

587


What is a nested loop?

643


What's the difference between constant char *p and char * constant p?

651


write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.

14955


Differentiate between full, complete & perfect binary trees.

667


An arrangement of information in memory in such a way that it can be easily accessed and processed by a programming language a) string b) data structure c) pointers d) array

683


What is the size of enum in bytes?

579


What is anagram in c?

512