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
Describe how arrays can be passed to a user defined function
What math functions are available for integers? For floating point?
Is c easier than java?
1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321
In a byte, what is the maximum decimal number that you can accommodate?
why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above
What is methods in c?
i got 75% in all semester am i eligible for your company
What is nested structure with example?
How can I find out how much free space is available on disk?
Does c have circular shift operators?
What is bss in c?
How do you declare a variable that will hold string values?
Are there namespaces in c?
How would you use the functions fseek(), freed(), fwrite() and ftell()?