History:Database Installation/Mac OS X Panther
Installing the MusicBrainz database on Mac OS X Panther
Installing the MusicBrainzDatabase onto Mac OS X Panther is relatively straightforward but there are a couple of things to look out for, hence the following instructions. There is no existing setup required except a standard Panther install and the Apple Developer Tools.
- Install Postgres
- Install some Perl Modules - DBI and DBD::Pg
- Download the mb_server module
- Download the data
- Run the import script
- Access the data with a GUI
There is a double-clickable Mac OS X Package installer version provided by Marc Liyanage available from http://www.entropy.ch/software/macosx/postgresql/ along with some instructions for completeing the setup, the relevant parts of which I'll reproduce below:
1. Download and install the packagepgsql-7.3.3.pkg.tar.gz (http://www2.entropy.ch/download/pgsql-7.3.3.pkg.tar.gz)
(Note: If you get the message You cannot install this software on this disk. (null), try to click the Go Back and then the Continue buttons.
2. Create a new user in the Users System Prefs pane:
Name: PostgreSQL User
Short Name: postgres
Password: whatever you want
3. Open a terminal window and type in the following commands:
- type sudo chown -R postgres /usr/local/pgsql/, enter administrator password when asked
- type su - postgres, enter the password of the newly created postgres user when asked
- type /usr/local/bin/initdb -D /usr/local/pgsql/data and wait for the operation to complete
- type /usr/local/bin/pg_ctl -D /usr/local/pgsql/data -l postgres.log start
4. Now you can create a test database with /usr/local/bin/createdb test
5. Use it with the built in command line interface by entering /usr/local/bin/psql test
Make a point of creating the test database at the end as you can use it to verify the installation of a Perl module later on.
(Note: Apparently if you change the postgres user id # to less than 500 in netinfo it stops it showing up in your login panel. I've not bothered myself.)
Also Marc mentions that you may need to alter some system configuration parameters to get it working. I didn't need to do this and think that they are only necessary for large databases. However check out his full instructions if you run into trouble.
Install Some Perl Database Modules
You need to install two Modules, DBI and DBD::Pg
The first one is easy:
sudo perl -MCPAN -e 'install DBI'
If you don't know what you're doing answer 'no' to the first question it asks and it will set itself up with the appropriate defaults.
Note that according to Tim Bray (http://www.tbray.org/ongoing/When/200x/2003/10/25/Panther) cpan install DBI should work too but I haven't tried it that way myself.
The second one (DBD::Pg) is trickier. The following instructions are lifted from http://www.visualdistortion.org/adium/technical.html#parser.pl
There are a few environmental variables that need to be set to allow the CPAN compile process to find the various libraries PostgreSQL installs. Set them using the following syntax if you are running Bash as your shell (which is the default under Panther):
export POSTGRES_LIB="/usr/local/pgsql/lib -lssl -lcrypto"
Note that in the original instructions it said "username" twice. I've changed one to "database" as I think it is a typo. If you use the name of the test database that Marc Liyanage's intructions ask you to create (i.e. "test") and username postgres with whatever password you chose then you should be fine.
If you run the install now, you will probably see errors relating to ranlib or libpq.a. Just run the following command preemptively:
sudo ranlib /usr/local/pgsql/lib/libpq.a
After running that, you can finally install DBD::Pg by entering:
sudo perl -MCPAN -e 'install DBD::Pg'
Download the mb_server module
I can't beat the simple instructions found at http://musicbrainz.org/development/cvs.html, except to remind you that you only need the mb_server module in order to access the database.
Download the Data
Download the four data dumps from http://musicbrainz.org/products/server/download.html (four not counting the RDF dump, which you don't need)
Note that Safari can be set to automatically expand compressed files, you probably want to disable that before downloading these files as the import script will uncompress them itself.
Run the Installer
You can edit mb_server/cgi-bin/DBDefs.pm and set DSN, DB_NAME, DB_USER and DB_PASSWD to the values of your own choosing. It's not necessary though, but you can have a look to see what the values are (database name, username and password are musicbrainz_db, musicbrainz_user, and blank by default)
mb_server/admin/InitDb.pl --createdb --import mb*.tar.bz2
I'm not sure if this is obvious or not but mb*.tar.bz2 refers to all the data dumps you just downloaded. So to run this with the exact command shown above you would need to be in your home directory and have the mb_server directory and all the bz2 archives located there as well.
After you run it find something else to do while it churns away for an hour or so.
Access the data with a GUI
You can get started right away by using the command line interface psql (found in /usr/local/bin/psql which may not be in your path) but I'd recommend using DbVisualiser. It's not obvious from the website but there is a totally free and relatively uncrippled version of the software available to download despite giving every impression that you can only get a 14-day limited trial. You *will* have to supply an email though.
By default Marc Liyanage's package installs Postgres without enabling access from other machines. This is also the mechanism used to connect to the database with a GUI so you need to add -o -i to enable that option. The following lines start or restart the database server with it enabled. (warning: typing from memory, will check these later)
/usr/local/bin/pg_ctl -D /usr/local/pgsql/data -l postgres.log -o -i start
/usr/local/bin/pg_ctl -D /usr/local/pgsql/data -l postgres.log -o -i restart
Once you've done that start DbVisualiser and from the menu choose Database -> Driver Manager... and locate the JDBC driver that was installed along with Postgres. (It will be a file called postgres.jar in /usr/local/pgsql/share/java/) then go to Database -> Add Database Connection and fill in the blanks as follows:
'''Connection Method:''' JDBC Driver
'''Connection Alias:''' MusicBrainz ''(or whatever you want)''
'''JDBC Driver:''' org.postgresql.Driver ''(chosen from drop-down)''
'''Database URL:''' jdbc:postgresql:musicbrainz_db ''(assuming you didn't change the database name from 'musicbrainz_db' which is the default)''
'''UserID:''' musicbrainz_user ''(again this is assuming you haven't changed the default in the previous step)''
'''Password:''' ''whatever you chose''
I'd also recommend switching to the Properties tab (in the row of tabs at the bottom) and checking the box for Show only the Default Database or Schema as it removes a great deal of excess clutter.
Then hit Connect and you should be done.