# Overview

After downloading the required software, we recommend installing in this order: MySQL, Java, then Winston. If you already have Java and/or MySQL running, please ensure that the versions are sufficiently current. Winston requires at least MySQL version 4.0, and Java 1.4. Better performance will be achieved with MySQL 4.1 vs 4.0.

# Installing MySQL

If you already have a MySQL installation running that you're happy with (provided it's at least version 4.0) then just skip to 7 below.

1. Extract the .zip file to `C:\` or on Linux/Unix, untar the binary distribution to a directory of your choosing

2. Install the MySQL server as a Windows service: open a command prompt and `cd` to `C:\mysql-4.1.11-win32\bin` and type: `mysqld --install`. (This step is not required for Linux/Unix).

3. On Windows, Start the service by typing: `net start MySQL`, or via Control Panel\Administrative Tools\Services. Once the service is started it will automatically restart at boot time. For Linux/Unix start the server by executing: `/path/to/mysql/bin/mysqld_safe --log-slow-queries`. Probably you'll want to put this process in the background. Also, you'll probably want to make the server start at boot.

4. Test that the server is running properly by executing the mysql client program. While in the mysql binaries directory (for Windows this is `C:\mysql-4.1.11-win32\bin`) type: `mysql -u root`. If you get something that looks like this: `
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 4.1.11
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>`
then things are working properly.

5. OPTIONAL. You may want to add the mysql binaries directory to your path for convenience.

6. You'll probably want to add a password to your root mysql user. At a command prompt, assuming you're in the mysql binaries directory, or that this directory is in your path, type: `mysqladmin -u root password newpass`, where `newpass` denotes the password you choose.

7. Create a Winston mysql user. Start the mysql client as in 5 above (if you created a root password, you'll need to add a `-p` option, which will cause the client to prompt you for a password before starting). At the `mysql>` prompt, type the following three commands:
`grant all on `W\_%`.* to wwsuser@'localhost' identified by 'wwspass';
flush privileges;`
Note that those are back ticks surrounding `W_%`, not single quotes. You might want to just cut and paste this whole line. You can call the Winston user whatever you want (we called it wwsuser here); the password can also be whatever you like. These grant commands permit the Winston user to have full control over any database that begins with `W_`. No other database will be touched under any circumstances, so you need not worry that Winston will clobber pre-existing data.

Warning: In the section on configuration files, we describe how `ImportEW` and `W` connect to the database via a JDBC url. Note that if the `localhost` in the url resolves to something other than literal `localhost` such as your machine name, then you'll need to change the above `grant` appropriately. For example, on the AVO machine `avo-valve.wr.usgs.gov` the command `ping localhost` returns this: `
PING avo-valve (127.0.0.1) 56(84) bytes of data.
64 bytes from avo-valve (127.0.0.1): icmp_seq=0 ttl=64 time=0.000 ms
64 bytes from avo-valve (127.0.0.1): icmp_seq=1 ttl=64 time=0.000 ms
--- avo-valve ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.000/0.000/0.000/0.000 ms, pipe 2`
hence `localhost` is getting resolved to `avo-valve`. So, the `grant` command should be as follows:
`grant all on `W\_%`.* to wwsuser@'avo-valve' identified by 'wwspass';`
A shortcut that avoids all these resolution issues is to simply grant access to `wwsuser` from all hosts via:
`grant all on `W\_%`.* to wwsuser@'%' identified by 'wwspass';`
though under some circumstances this is less secure.

Warning: Your installation of MySQL must allow TCP/IP connections. This is the default setting, so no action needs to be taken unless you have specfically denied TCP/IP connections.

# Installing Java

1. For Windows, simply run the executable, self-extracting Java installer program. For Linux/Unix, untar the Java distribution into a directory of your choosing.

2. Add the Java binary directories to you path. (This is done automatically by the Windows installer)

3. Test the installation by typing: `java -version` at a command line. If you get something back like this: `
java version "1.5.0_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09)
Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode, sharing)
` then you're in business. Remember, Java 1.4 or higher is needed.

# Installing Winston

1. For Windows, unzip the Winston binary distribution into `C:\`. For Linux/Unix, untar the Winston distribution into a directory of your choosing.

2. Test the Winston software. At the command line type, execute `WinstonVersion.bat` (Windows) or `WinstonVersion.sh` (Linux/Unix). If you see something like this: `
Version: 1.0.0
Built: 2005-04-27 08:22:33
` then everything is working fine. If the test script did not execute properly, then make sure that the `java` program is still in your path.