Wednesday, December 31, 2008

MySQL 5 and create_sguildb.sql script

While installing Sguil on my main desktop using the NSMNow scripts, I encountered many moderately vexing challenges. I did not encounter any challenges installing Sguil on my notebook, so this added to my frustration. I am running Ubuntu 8.10 on my desktop and 7.10 on my notebook. This post will deal with the challenges that I encountered configuring the sguildb using the create_sguidb.sql script.

While attempting to use the create_sguildb.sql script I encountered the following MySQL error:

inuk-x@shell:~$ mysql -u sguil -p -D sguildb < create_sguildb.sql
Enter password:
ERROR 1064 (42000) at line 55: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to usenear '--)' at line 1

Fortunately a quick Google search produced a forum question that gave me enough information to figure out that there must be something wrong with the comments in the create_sguildb.sql script, so another Google search produced the answer from the MySQL 5.0 Reference Manual.

It turns out that this error is being generated because double-dash style comments in MySQL 5 require a minimum of one whitespace or control character after the second dash. Lines 55, 57, 58, 71, 72, 79, 80, 88, 89, 210, 211 and 234 of the create_sguildb.sql script do not follow this new syntax.

Comparing a modified create_sguildb.sql file with the original produces the following output:

inuk-x@shell:~$ diff sguil-0.7.0/server/sql_scripts/create_sguildb.sql.modified sguil/server/sql_scripts/create_sguildb.sql.original
55c55
< -- ); --- > --);
57,58c57,58
< -- CREATE TABLE tcphdr < -- ( --- > --CREATE TABLE tcphdr
> --(
71,72c71,72
< -- CREATE TABLE udphdr < -- ( --- > --CREATE TABLE udphdr
> --(
79,80c79,80
< -- CREATE TABLE icmphdr < -- ( --- > --CREATE TABLE icmphdr
> --(
88,89c88,89
< -- CREATE TABLE data < -- ( --- > --CREATE TABLE data
> --(
210,211c210,211
< -- CREATE TABLE sancp < -- ( --- > --CREATE TABLE sancp
> --(
234c234
< -- ); --- > --);

Once I modified this script with the proper comment syntax, I was able to run the script properly and create the sguildb.

0 comments: