FAQ written by: ssnelgrove
The “SER Getting Started” manual is very good except that the details of getting SERi [1] to work with MySQL are hard to understand. The point of view in this document is that you are building SER from source (high experience level) and that you are very familiar with MySQL (also high experience level). This contrasts a little with the assumed experience level of the document which starts out at the “Hello World” level. Many people will just be trying a binary installation at first and so this section will often be above their level.
Here are some pointers on getting MySQL to work with SER. This will assume that about all you know is that MySQL is a database that uses SQL.
Installing MySQL
This section will of course vary by system type but in most cases there are broad similarities that can be illustrated by a few specific examples.
In Fedora, you can as root execute the command “yum –y install mysql”.
Verifying that MySQL is installed
MySQL is a two part, client server type of application. There is a database server that clients talk to via a TCP socket. The command line utility “mysql” is a client that will attempt to talk to the database server.
Out of the box, the mysql program does not require a password. So from the command line just execute the simple command “mysql”. You should get a prompt like “->”. To quit enter the command “quit;”. Note the semicolon. All commands in this mini-shell should be terminated with a semicolon. Otherwise, the command line interpreter will assume that you are doing a multi-line command and will prompt for additional input.
Now enter the command “show tables;”. You should see two default tables “mysql” and “test”. You can at this point enter commands like “describe test;” or “use test; select * from test;”. Now quit and we will proceed to the description of getting the SER database tables installed.
It may be that when you enter the command “mysql” you will get an error saying “ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)”. This means that a password has been set for controlling access to the database. Hopefully, you are the person who set the password and you remember it.
Once a password has been set for the database, the only way into the mysql program is to enter a command line argument “-p”. Specifying “-p” by itself will cause the mysql program to prompt for a password before attempting to connect to the database server.
You can also enter an actual password on the command line using “-pxxxxxxx” where the x’s represent the actual password. Note that there is no space after the “-p”. Obviously, this puts the password out in plain view and is probably not what you want to do as a rule.
Another command line argument that is useful in connection with a password the the “-u” option that allows specification of a user. By default, the mysql client program will assume that the use is your login username. If you want to enter the program as someone else use this option. For example, you could invoke the program as “mysql –u admin –p” to access the database as user “admin” and the program will prompt you for a password.
Setting up the SER database
When using the SER system with the mysql modules, there is an assumption within SER that certain tables and accounts will exist in the database. How do these get created initially? Well from what we know so far, we could execute the mysql command and start adding tables and populating these tables with the required values. This is obviously bad because it would require a total understanding of the SER application and its requirements of the database. Luckily the SER developers have a shell script, “ser_mysql.sh”, that encodes this knowledge.
This script resides by default in the directory “/usr/local/sbin” and should be executed as root. The script assumes that a password has been set for root access into the database. If you have a brand new install of MySQL, this will not have been done and must be done now before you can proceed. Enter the command “mysqladmin -u root password xxxxxx” where the x’s represent your password. This password may be your root login password or you may choose a special password for admintering the database. Since this password will reside in the MySQL database you should consider the fact that there are security considerations in having a copy of your root login password in muliple places.
So now at this point, you should no longer be able to invoke the mysql client by just entering the name alone. You must now use the “-p” option to ask the client to prompt you for your password. Now we are ready to run the SER database installation script.
Invoking seri [2]_mysql.sh
The ser_mysql.sh script is a general database maintanence script and contains serveral options. Invoking the script by simply entering the name will produce a listing of the command options. Choose the create option and enter the command as follows “ser_mysql.sh create”. If all goes well, great. If errors occur, it might be helpful to know where in the script the problem is occuring. To do this enter the command as “sh –x ser_mysql.sh create”. This will echo the command as the shell interprets them and will allow you to see the source line of the error.
This script will as for the root password to be entered and also for a “realm”. What is the “realm” and why does the script need this information? One might assume that the “realm” is the same as the output of the “hostname” command. It might be that the “realm” is the name of the machine where the database will be located and that this information will be used in attempting to connect to the database. In this case, using the same name as is returned by “hostname” is the correct thing to enter at this prompt unless the database is residing on another server (a topic somewhat above the Hello World level).