Skip to end of metadata
Go to start of metadata

If you provisioned a SmartMachine from the SmartMachine Standard image or if you have installed SmartMachine Tools Package, you can take advantage of scripts that help you manage databases and database users. You can use these scripts to:

  • Create a database
  • Create a database user
  • List all databases
  • List all database users
  • Remove a database
  • Remove a database user

These scripts are located in /opt/local/bin/.

In this topic:

At a Glance

This topic shows you how to manage databases through the pre-defined scripts on SmartMachines provisioned from a SmartOS Standard image.

Creating a Database

You create a new database on a SmartMachine by invoking the sm-create-db script. The script is located in /opt/local/bin/sm-create-db.

Before you Begin

Before invoking this script, ensure you know the following. You will pass these in as arguments for the script:

  • The type of database you want to create.
  • The name you will use for the database.
  • A valid database user name and password with admin rights. You specify this using the -u and -p options respectively.
    You only need to pass in an admin username and password if you change your login credentials after signing up for a Joyent Public Cloud account.

Invoking the Script

To invoke the script:

  1. SSH into your SmartMachine.
  2. Run the sm-create-db command specifying the database type and database name. For example:
    If necessary, include the -u and -p arguments.

If successful, the script will display a confirmation message.

Creating a Database User

You create a new database on a SmartMachine by invoking the sm-create-dbuser script. This script is located in /opt/local/bin/sm-create-dbuser.

Before you Begin

Before invoking this script, ensure you know the following. You will pass these in as arguments for the script:

  • The type of database to which you are adding a user: mysql or postgresql.
  • The database user's password.
  • The database user's username.
  • The name of the database.
  • A valid database user name and password with admin rights. You specify this using the -u and -p options respectively.
    You only need to pass in an admin username and password if you change your login credentials after signing up for a Joyent Public Cloud account.

Invoking the Script

To invoke the script:

  1. SSH into your SmartMachine.
  2. Run the sm-create-dbuser command specifying the database type, database name, username and user password. For example:
    If necessary, include the -u and -p arguments.

If successful, the script will display a confirmation message.

List All Databases

You can list all installed databases on a SmartMachine by invoking the sm-list-dbs script. This script is located in /opt/local/bin/sm-list-dbs.

Before you Begin

Before invoking this script, ensure you know the following. You will pass these in as arguments for the script:

  • The type of database for which you would like to generate a list: mysql or postgresql.
  • A valid database user name and password with admin rights. You specify this using the -u and -p options respectively.
    You only need to pass in an admin username and password if you change your login credentials after signing up for a Joyent Public Cloud account.

Invoking the Script

To invoke the script:

  1. SSH into your SmartMachine.
  2. Run the sm-list-dbs command specifying the database type. For example:
    If necessary, include the -u and -p arguments.

If successful, you will see a list of all the databases installed on the SmartMachine.

List all Database Users

You can list all database user accounts on a SmartMachine by invoking the sm-list-dbusers script. This script is located in /opt/local/bin/sm-list-dbusers.

Before you Begin

Before invoking this script, ensure you know the following. You will pass these in as arguments for the script:

  • The type of database for which you would like to generate a user list: mysql or postgresql.
  • A valid database user name and password with admin rights. You specify this using the -u and -p options respectively.
    You only need to pass in an admin username and password if you change your login credentials after signing up for a Joyent Public Cloud account.

Invoking the Script

To invoke the script:

  1. SSH into your SmartMachine.
  2. Run the sm-list-dbusers command specifying the database type. For example:
    If necessary, include the -u and -p arguments.

If successful, you will see a list of all the database user accounts on the SmartMachine.

Remove a Database

You can remove an installed database on a SmartMachine by invoking the sm-remove-db script. This script is located in /opt/local/bin/sm-remove-db.

Before you Begin

Before invoking this script, ensure you know the following. You will pass these in as arguments for the script:

  • The type of database you want to remove: mysql or postgresql.
  • The name of the database.
  • A valid database user name and password with admin rights. You specify this using the -u and -p options respectively.
    You only need to pass in an admin username and password if you change your login credentials after signing up for a Joyent Public Cloud account.

Invoking the Script

To invoke the script:

  1. SSH into your SmartMachine.
  2. Run the sm-remove-db command specifying the database type and the database name. For example:
    If necessary, include the -u and -p arguments.

If successful, the script will display a confirmation message.

Remove a Database User

You can remove a database user account on a SmartMachine by invoking the sm-remove-dbuser script. This script is located in /opt/local/bin/sm-remove-dbuser.

Before you Begin

Before invoking this script, ensure you know the following. You will pass these in as arguments for the script:

  • The type of database: mysql or postgresql.
  • The user name of the account you want to remove.
  • A valid database user name and password with admin rights. You specify this using the -u and -p options respectively.
    You only need to pass in an admin username and password if you change your login credentials after signing up for a Joyent Public Cloud account.

Invoking the Script

To invoke the script:

  1. SSH into your SmartMachine.
  2. Run the sm-remove-dbuser command specifying the database type and the user name for the account you want to remove. For example:
    If necessary, include the -u and -p arguments.

If successful, the script will display a confirmation message.

Labels:
smartmachine smartmachine Delete
standard standard Delete
creating creating Delete
database database Delete
user user Delete
list list Delete
remove remove Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.