                          GpsDrive MySQL README
                          =====================
Contents
========
* Introduction
* Install
* Initialise the Database
* Insert Openstreetmap Data (Optional)
* About Openstreetmap
* Converting a track log ready for upload to Openstreetmap <TODO>
* MySQL Options in GpsDrive <TODO>
* Compile MySQL (if you must)

<TODO> There is still some useful information in README.SQL but lots of it is out of date.
       The relevant parts should be added to this file and README.SQL should be removed
       to avoid confusion.

Introduction
============
Firstly you don't absolutely need MySQL to use GpsDrive. It will happily 
store the basic information it needs in flat files.  However if you want 
to use some of the more advanced features then you will need MySQL.  
Other databases may be supported in the future but at the moment they 
aren't. GpsDrive automatically detects if MySQL is 
running and if it is it running it will use it.  

Install
=======
The best way to install MySQL is to use the package manager that comes with 
your flavour of Linux.  If for some reason this isn't possible then the next 
best thing is to download a ready made package file from the following 
location http://dev.mysql.com/downloads/mysql/5.0.html.  

Don't forget your copy of Linux may have come with MySQL pre-installed.

If you still can't find what you need then download the source tar ball (at 
the bottom of the page) and check out the compile instructions below. 
(not for the faint hearted)

<TODO> Minimum required version of MySQL.
(I'm not sure of the minimum but I'm using 5.0.22)

Initialise the Database
=======================
Once you have MySQL up and running you can use these scripts to initialise 
the database for GpsDrive.  This task was previously performed by a script 
called create.sql which is out of date and no longer being maintained.

Change directory to GpsDrive's bin folder then run the following command.

./geoinfo.pl -create-db -fill-defaults -openstreetmap \
	-db-user=root -db-password=<yourpassword> 

If you have installed GpsDrive into a directory other than the default you 
may need to update the perl library path before running the command.  Change 
the path depending on your installation.

export PERL5LIB=/<your path>/gpsdrive/share/perl5

if you have not set a root password for your mysql installation, you can reset 
it with the following command:
   echo " UPDATE user SET Password=PASSWORD('new_password') WHERE user='root'; FLUSH PRIVILEGES;" |mysql -u root mysql
where new_password is the new password for root.

Insert Openstreetmap Data (Optional)
====================================
The following command downloads and inserts the openstreetmap street 
info for Earth! from planet.openstreetmap.org/ to you local mysql. 

./geoinfo.pl --db-user=root --db-password=<yourpassword> --no-delete --osm

Now that you have MySQL up and running and have some data in there you 
should see extra options in the menu on the left hand side when you start up GpsDrive.

About Openstreetmap
===================
Rather than me describe it here you are better off to go check it out here.
http://openstreetmap.org.  In a line (or two), it is a free to use, user 
updatable database containing vector bassed street maps covering the whole 
world. Users like you and me upload their gps track information and then 
draw the streets in over top of the tracks. It is fun once you start 
seeing results.

Converting a track log ready for upload to Openstreetmap
=======================================================
just use osmtrackfilter


MySQL Options in Gpsdrive
=========================
<TODO>


Compile MySQL (if you must)
===========================
There seems to be tons of options to compile mysql.
I found a recommended set of options and then modified them until I
managed a clean compile.  I just googled the errors and modified the options.

I'd certainly recommend doing a 'make test' to ensure everything is ok.  The built in 
tests are quite comprehensive.

The only additional package you will need if you are compiling gpsdrive on the same system is.

libcurses5-dev

Below is the command I used to configure mysql on both debian and DSL.
For the full script I used see  DSL/build-mysql.sh which worked on mysql version 5.0.22

Set $DEST to what ever you want or leave --prefix out for a default install.

CFLAGS="-O3 -DPIC -fPIC -DUNDEF_HAVE_INITGROUPS -fno-strict-aliasing" \
CXXFLAGS="-O3 -fno-strict-aliasing -felide-constructors -fno-exceptions -fno-rtti -fPIC -DPIC -DUNDEF_HAVE_INITGROUPS" \
    ./configure --prefix=$DEST \
    --enable-thread-safe-client \
    --enable-assembler \
    --enable-local-infile \
    --with-unix-socket-path=/var/run/mysqld/mysqld.sock \
    --without-debug \
    --without-yassl \
    --without-bench \
    --with-extra-charsets=complex 

Don't be afraid to read the documentation on mysql.org.  It is quite extensive and will save you heaps of time trying to figure it all out your self.

MySQL Password
==============
If you forgot or never set your mysql root password, try
 mysqladmin -u root password "mynewpassword"

If you compile it your self the password may be blank.

Uninstall geoinfo in MySQL
==========================

Warning: This will really delete all modifications you 
have made to the local geoinfo database.

 echo "drop database geoinfo;"| mysql -uroot -pyour_mysql_root_password

