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
Explain modulus operator. What are the restrictions of a modulus operator?
What language is lisp written in?
What are dangling pointers in c?
What is a static variable in c?
what are # pragma staments?
The number of measuring units from an arbitarary starting point in a record,area,or control block to some other point a) recording pointer b) offset c) branching d) none
What is a nested formula?
What are high level languages like C and FORTRAN also known as?
What is the use of #include in c?
Explain what is meant by high-order and low-order bytes?
What are the different file extensions involved when programming in C?
What is a null string in c?
In C, What is the #line used for?
What is meant by type specifiers?
how to make a scientific calculater ?