• MySQL – create and delete databases

    Login

    First thing is to log into your Slice via the terminal or PuTTY, etc and then log into MySQL:

    mysql -u root -p

    You will be prompted for your MySQL root password (note this is not the same as the Slice root password).

    Creating a database

    Let’s start by creating a new database called ‘mytestdb’:

    CREATE DATABASE mytestdb;

    The output is as follows:

    mysql> CREATE DATABASE mytestdb; Query OK, 1 row affected (0.00 sec)

    Let’s have a quick look:

    mysql> SHOW databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | mytestdb | +--------------------+ 3 rows in set (0.00 sec)

    You can see the new database we just created.

    Dropping a database

    Seems easy enough and dropping (deleting) a database is just as easy.

    Let’s delete the ‘mytestdb’ database we just created:

    DROP DATABASE mytestdb;

    Done.

    Always nice to check though:

    mysql> SHOW databases;
     +--------------------+ | Database | +--------------------+ | information_schema | | mysql | +--------------------+ 2 rows in set (0.00 sec)

    Categories: Mysql

    Leave a Reply