How to install SchemaSpy for a database in Ubuntu 12.04?

Step 1: Download dependencies :

1.  Graphviz

sudo apt-get install graphviz

To check which version is installed, type:

dot -V

2. ConnectorJ

wget –spider "http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.0.8.zip/from/http://mysql.he.net/"

unzip mysql-connector-java-5.0.8.zip

Add it to your includes

3. Java – JDK, JRE

Follow the following steps:

1. Issue following command to find out current jdk version in apt-get

apt-cache search jdk

2. Install java JDK and JRE with apt-get install

apt-get install sun-java6-jdk sun-java6-jre

3. Ubuntu will auto download necessary file from web for installation.
4. After installation done, jdk and jre will install at /usr/lib/jvm/java-6-sun-1.6.0.06

5. Ubuntu help to create a java symbolic link and put in /usr/bin for shortcut access

4. type java -version, DONE !!

Post Installation Setup:

Set JAVA_HOME into environment variable

Copy following statement and append to /etc/profile or .bashrc file, make system set JAVA_HOME into system environment variable.

export JAVA_HOME="/usr/lib/jvm/java-6-sun-1.6.0.06"

Step 2: Download SchemaSpy 5.0

wget "http://sourceforge.net/projects/schemaspy/files/schemaspy/SchemaSpy%205.0.0/schemaSpy_5.0.0.jar/download" -O schemaSpy_5.0.0.jar

Step 3: Run schemaSpy

java -jar schemaSpy.jar -t mysql -o library -host localhost -db db_name   -u user -p password -dp /usr/share/java/mysql-connector-java.jar

Description of parameters used in above command:

-t databaseType: Type of Database(e.g ora,db2 etc.)
-db db_name: Name of the Database to connect to.
-u user: Valid database user id with read access.
-s schema: Database schema.
-p password: Password associated with that user.
-o output Directory: Directory to write the generated HTML/graphs to.
-dp path/To/Drivers: Looks for drivers here before looking in driverPath in [databaseType].properties. The drivers are usually contained in .jar or .zip files and are typically provided by your database vendor.

* Your Library folder has been created in /home , open the library folder and you can run any of the files in browser and understand relationships among different tables in database.

You will get this while executing the above command.

Using database properties:
  [schemaSpy_5.0.0.jar]/net/sourceforge/schemaspy/dbTypes/mysql.properties
Gathering schema details................................................................................(1sec)
Writing/graphing summary............(1sec)
Writing/diagramming details.............................................................................(10sec)
Wrote relationship details of 77 tables/views to directory 'library' in 13 seconds.
View the results by opening library/index.html

Step 4: Create a symlink in www directory

cd /var/www 

sudo ln -s /path/to/output_folder DB_Name

Here the output_folder is library.

Remember apache must be able to follow symlinks and must have atleast read+execute perms.

Step 5: Point your browser to : localhost/DB_Name


…and you should see what you DB looks like schema wise. 🙂

Advertisements

About Priyanka Kapoor

Simple, Hardworking & friendly.....
This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to How to install SchemaSpy for a database in Ubuntu 12.04?

  1. Step 2:
    2. ConnectorJ
    Add it to your includes
    Which include you are talking about?

  2. On unziping the folder, you get a mysql-connector-java.jar file. Place it in /usr/share/java/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s