CARNEGIE MELLON UNIVERSITY
15-826 - Multimedia databases and data mining
Fall 2011 C. Faloutsos

Steps to setup a MySQL server

Supported Setup: on Andrew Linux machines (command line)

Important: Replace ANDREWID with your andrew id in all the scripts below. And also replace $MYSQLBASE with the appropriate path to where you unzipped the mysql archive - it will be something like /afs/andrew.cmu.edu/usr2/ANDREWID/mysql Login on an andrew linux machine, and then:
  1. Download MySQL Community Server 5.5.8 Linux - Generic Compressed TAR Archive
  2. Unpack it. For example to: /afs/andrew.cmu.edu/usr2/ANDREWID/mysql

    tar -xvf mysql-5.5.15-linux2.6-x86_64.tar.gz
    mv mysql-5.5.15-linux2.6-x86_64 mysql
    setenv MYSQLBASE /afs/andrew.cmu.edu/usr2/ANDREWID/mysql

  3. Go to the $MYSQLBASE directory and install SQL:

    scripts/mysql_install_db --datadir=$MYSQLBASE/data --user=ANDREWID

  4. Make a directory for the socket used by the client/server dialogue - this should not be on afs space:

    mkdir /tmp/ANDREWID

  5. Start the mysql server:

    bin/mysqld --basedir=$MYSQLBASE --datadir=$MYSQLBASE/data --log-error=$MYSQLBASE/data/mysql.err --pid-file=$MYSQLBASE/mysql.pid --socket=/tmp/ANDREWID/mysql.sock --port=3308 --user=ANDREWID

    Alternative to start mysql server (if you get an error when connecting with the client):

    bin/mysqld --basedir=$MYSQLBASE --datadir=$MYSQLBASE/data --log-error=$MYSQLBASE/data/mysql.err --pid-file=$MYSQLBASE/mysql.pid --socket=/tmp/ANDREWID/mysql.sock --port=3308 --user=ANDREWID --skip-innodb --default-storage-engine=myisam

  6. Connect to the server:

    bin/mysql --socket=/tmp/ANDREWID/mysql.sock -u root

  7. Once connected to the sql server, a prompt should appear. Use the following commands to create a new schema - before executing the commands indicated in the homework:

    > create database dbtest
    > use dbtest

  8. To shut down the server:

    bin/mysqladmin -u root --socket=/tmp/ANDREWID/mysql.sock shutdown

OPTIONAL, unsupported setup: on your machine (with GUI)

You are welcome to set up a server on your machine and enjoy a GUI, but then you are on your own. You may find these pointers useful:
Note: User and schema creation, as well as permission assignment can be done through queries that edit the mysql schema. Check the manual for CREATE USER, CREATE SCHEMA and GRANT/REVOKE.

OPTIONAL, unsupported, fall-back set up: sqlite3

You are welcome to use sqlite3 but it has slight syntax differences from MySQL, that you need to account for, on your own.

If you choose this set up: The above example will create a file ('hw0.db' in this case), which will contain all the tables/views/indices that you care to create and populate.
Last modified: Sept. 18, 2011, by Ina Fiterau and Christos Faloutsos.