DEV Community

Sualeh Fatehi
Sualeh Fatehi

Posted on • Updated on

How to Visualize Your MySql Database with One Command (and Nothing to Install)

Ever wondered what the tables in your MySql database look like, and how they are related to each other? Generate a diagram of your MySql database with one command. You can run this on any system that has Docker installed.

On a Linux system, run a command like:

docker run \
--mount type=bind,source="$(pwd)",target=/home/schcrwlr \
--rm -it \
schemacrawler/schemacrawler \
/opt/schemacrawler/bin/schemacrawler.sh \
--server mysql \
--host mysql-rfam-public.ebi.ac.uk \
--port 4497 \
--user rfamro \
--password= \
--database Rfam \
--info-level standard \
--command schema \
--output-file rfam.pdf
Enter fullscreen mode Exit fullscreen mode

The command will generate an entity and relationship diagram of the the Rfam database of the European Bioinformatics Institute. A file called "rfam.pdf" will be generated with the database schema, including foreign key relationships.

If you are using PowerShell on Windows, replace the trailing backslash on each line with a back-tick, and map the current directory differently. Run this command:

docker run `
--mount type=bind,source="${PWD}",target=/home/schcrwlr `
--rm -it `
schemacrawler/schemacrawler `
/opt/schemacrawler/bin/schemacrawler.sh `
--server mysql `
--host mysql-rfam-public.ebi.ac.uk `
--port 4497 `
--user rfamro `
--password= `
--database Rfam `
--info-level standard `
--command schema `
--output-file rfam.pdf
Enter fullscreen mode Exit fullscreen mode

You can generate PDF files, and other types of output too. Go through the SchemaCrawler tutorials on Katacoda to learn more SchemaCrawler commands.

Top comments (4)

Collapse
 
adriens profile image
adriens

Go to killercoda.com/schemacrawler for up-to-date Schemacrawler course

Collapse
 
jplindstrom profile image
Johan Lindstrom

Does this actually work?

I'm just getting

SchemaCrawler 16.16.7

Error: Graphviz was not available to create the requested diagram.

Please reinstall Graphviz, and make it available on the 
system PATH. If you are unable to install Graphviz, make
https://github.com/nidi3/graphviz-java jar files available
to SchemaCrawler, in the lib/ folder. Otherwise, consider 
generating a DOT file in scdot format.
Enter fullscreen mode Exit fullscreen mode
Collapse
 
sualeh profile image
Sualeh Fatehi

Yes, it does work. The error is possibly due to incorrect mapping of the output paths for the diagram image file. Please follow the steps exactly, and also take a look at github.com/schemacrawler/SchemaCra...
Then you will need to work out how to map the paths correctly for your use case.

Collapse
 
adriens profile image
adriens

Hi @sualeh : could you please provide us the killercoda version ?