How to list MySQL databases through command line ?

List MySQL databases through command line.

  1. Bhawani Singh
    To list MySQL databases you have to login as root user. You can use mysql command to list all available databases. MySQL is simple command line tool which is simple and easy in use.

    First, you have to login into the MySQL server through this command line ;
    -----
    # mysql -u root -p *****
    -----

    here, -u option is for username and -p option is for password.

    Now, you can open MySQL prompt through :
    -----
    # mysql>
    -----

    To list all databases availabele run this command :
    -----
    # SHOW DATABASES;
    -----

    Result will be similar to this :
    -----
    mysql> SHOW DATABASES;
    +--------------------+
    | Database |
    +--------------------+
    | information_schema |
    | mysql |
    | wiki |
    | test |
    +--------------------+
    4 rows in set (0.00 sec)

    -----