Setting Up the Example MySQL Database

These instructions help you set up the example MySQL database that is used throughout this chapter. A dump file for this database is located in <document_root>\examples\data\mysql\db_cordasamples . Among other things, the example data contains statistics for a fictional baseball league over a five-year period.

There are two sets of instructions:

To set up the example database on Windows

  1. If you haven't already, install MySQL.

    This is typically an easy install. The latest version of MySQL can be downloaded from http://www.mysql.com/.

    Note: The following procedure has only been tested with MySQL 3.23 and higher, but it should work with most versions of MySQL.

  2. If you haven't already, start the MySQL daemon.

    If MySQL has been installed as a service, please ignore this step. However, you may need to restart the computer before launching the service.

    To start MySQL in standalone mode, open a command prompt window and go to the bin folder of the MySQL installation. Assuming it was installed to its default location, you can change to this directory with the following command:

    cd c:\mysql\bin

    Once you are in this directory, run the following command:

    mysqld-nt --standalone

    MySQL takes control of the command prompt window. Be sure not to close this window—doing so stops MySQL.

    If you need further help starting MySQL, please consult the MySQL documentation.

  3. Open up a new command prompt window and once again go to the bin folder of the mysql installation.

  4. From that directory, run the following command:

    mysqladmin create CordaSamples

    The preceding command assumes an anonymous account for accessing mysql. If you do not have an anonymous account, add --user --password to the command. See Step 6 below.

  5. From that directory, run the following command:

    mysql CordaSamples < "C:\Corda\Corda7\Server\dev_tools\sql\mysql_cordasamples"

    If you have installed Corda® 7 in a location other than C:\Corda\Corda7, use the location where you installed Corda 7.

    If you receive an Access denied error, enter an appropriate user name and password. For example, if your user name is root and your password is corda, use the following command:

    mysql CordaSamples --user=root --password=corda < "C:\Corda\Corda7\ Server\dev_tools\sql\mysql_cordasamples"

    If you do not know what the password is, consult with a database administrator.

  6. Check to see that the CordaSamples database has been imported into the MySQL database.

    To do this, start the MySQL client by running the mysql command from the command line. If you receive an Access denied error, enter an appropriate user name and password, as illustrated below:

    mysql --user=root --password=corda

    Then, from the mysql command prompt, enter the following command:

    show databases;

    If the example database has been installed correctly, CordaSamples is in the list of databases.

 

To set up the example database on Linux/UNIX-compatible systems

  1. If you haven't already, install MySQL.

    This is typically an easy install. The latest version of MySQL can be downloaded from http://www.mysql.com/.

    Note: The following procedure has only been tested with MySQL 3.23 and higher, but it should work with most versions of MySQL.

  2. If you haven't already, start MySQL .

    Typically, MySQL is installed as a service, meaning that it automatically starts with the system. However, you may need to restart the computer before launching the service.

    If MySQL has not been installed as a service and you need help starting it, please consult the MySQL documentation.

  3. From that directory, run the following command:

    mysqladmin create CordaSamples

  4. From a command prompt, run the following command:

    mysql CordaSamples < /usr/local/Corda/Corda7/Resources/doc_root/image_templates/examples/data/mysql/db_cordasamples

    If you have installed Corda 7 in a location other than /usr/local/Corda/Corda7, use the location where you installed Corda 7.

    If you receive an Access denied error, enter an appropriate user name and password. For example, if your user name is root and your password is corda, use the following command:

    mysql CordaSamples --user=root --password=corda < /usr/local/Corda/Corda7/Resources/doc_root/image_templates/examples/data/mysql/db_cordasamples

    If you do not know what the password is, consult with a database administrator.

  5. Check to see that the CordaSamples database has been imported into the MySQL database.

    To do this, start the MySQL client by running the mysql command from the command line. If you receive an Access denied error, enter an appropriate user name and password, as illustrated below:

    mysql --user=root --password=corda

    Then, from the mysql command prompt, enter the following command:

    show databases;

    If the example database has been installed correctly, CordaSamples is in the list of databases.