1. Check if you have a mysql server installed

rpm -qa | grep mysql


ps -ef | grep mysql

if one of those commands return an output stop the mysql server, and check if is a 4.1.20 Mysql version. If you have Mysql Installed jump to point 4. below

2. How to install a MySQL from scratch.

Suppose to have a SLC4 machine without any MySQL DBMS previously installed. Download and run the following rmps.

yum install mysql-4.1.20-2.RHEL4.1.0.1
yum install mysql-server-4.1.20-2.RHEL4.1.0.1
yum install mysqlclient10-3.23.58-4.RHEL4.1
yum install mysql-connector-java-5.0.8-1jpp

Once the operations are completed you can check if everything is fine:

rpm -qa | grep mysql

3. Configure /etc/my.cnf

It's nececessary to set the defaults to INNODB.

Add the following settings under [mysqld] section in file /etc/my.cnf


4. Start mysql service as root user.

/sbin/service mysqld start

Check the service status as follows.

/sbin/service mysqld status
mysqld (pid xyz) is running..

5. Then it is necessary to create a delegationdb instance for Cream Delegation Service.

You may use the a mysql client to connect to the just installed dB as described below.

Check existing databases typing as root user the following:

show databases;
| Database |
| mysql    |
| test     |

If delegationdb is not already present, create the instance typing as root user the following:

create database delegationdb;

6. You need also to grant access to delegationdb to user named deleg. Manage grant privileges typing as root user the following:

grant all privileges on delegationdb.* to deleg@'localhost' identified by 'deleg21' with grant option;

Optionally, apply other privileges if it is necessary to monitor the database accessing from external hosts. You can skip this step if not required.

grant all privileges on delegationdb.* to deleg@'<hostname>' identified by 'deleg21' with grant option;

Where <hostname> is the host allowed to access the mysql server:
%               means that every host has access
%.pd.infn.it    means that every host in the pd.infn.it domain has access
mypc.pd.infn.it means that only the mypc host has access

7. Now you can populate the delegationdb database using populate_delegationdb.sql as SQL script file.

wget http://jra1mw.cvs.cern.ch/cgi-bin/jra1mw.cgi/org.glite.ce.cream/config/db/populate_delegationdb.sql?view=co -O populate_delegationdb_mysql.sql
mysql -u deleg -h localhost -pdeleg21 < populate_delegationdb_mysql.sql

8. Check that everything is OK typing:

mysql -u deleg -h localhost -pdeleg21
show databases;
| Database      |
| delegationdb  |
| test          |

9. There is no compile-time, but only a run-time, dependency to mysql JDBC jar. So it is sufficient to have the JDBC3 mysql-connector-java-5.0.8.jar archive in the classpath of Tomcat in which Cream is running. You can find the jar typing:

locate mysql-connector-java-5.0.8.jar

10. Configure MySQL JNDI DataSource in Tomcat.

Step1: Modify the web.xml. Add the following lines to the $CATALINA_HOME/webapps/ce-cream/WEB-INF/web.xml file before the closing element tag </web-app>.

    <description>DB Connection</description>

Step2: Add the Resource Element in the ce-cream.xml file. Edit the $CATALINA_HOME/conf/Catalina/localhost/ce-cream.xml and before the closing element tag </Context> add the following lines:

<Resource name="jdbc/dlg" 
          username="deleg" password="deleg21" driverClassName="com.mysql.jdbc.Driver"
          removeAbandoned="true" removeAbandonedTimeout="30"
          validationQuery="SELECT 1"

For further info see: