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
disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit
What is function what are the types of function?
Explain the difference between ++u and u++?
What is meant by errors and debugging?
write a progrmm in c language take user interface generate table using for loop?
What is a pointer in c plus plus?
What are the salient features of c languages?
Explain how can you be sure that a program follows the ansi c standard?
Why calloc is better than malloc?
What is the general form of #line preprocessor?
In a switch statement, explain what will happen if a break statement is omitted?
What is the usage of the pointer in c?
What is echo in c programming?
How will you write a code for accessing the length of an array without assigning it to another variable?
Explain modulus operator. What are the restrictions of a modulus operator?