MySQL command to show list of databases on server

I am a new Linux user and never used MySQL database server before. How do I show the list of databases on my server? Is there any good GUI frontend exists for the same purpose?

You can use the mysql command to connect to mysql server and list available databases.

Task: Mysql list databases

mysql is a simple command-line tool. mysql is command line and it is very easy to use. Invoke it from the prompt of your command interpreter as follows:
$ mysql
Sample outputs:

mysql>

You may need to provide mysql username, password and hostname, use:
$ mysql --user=your-user-name --password=your-password
OR
$ mysql -u your-user-name -p'Your-password' -h your-hostname

To list database type the following command at mysql prompot:

mysql> show databases;
Output:

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
+--------------------+
2 rows in set (0.00 sec)

In this sample output information_schema and mysql are name of databases. To use database and to list available tables type the following two commands:
mysql> use mysql;
Sample output:

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

Now list tables, run:
mysql> show tables;
Sample outputs:

+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| func                      |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| proc                      |
| procs_priv                |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
17 rows in set (0.00 sec)

mysql>

Shell one liner

Use the following one liner to get the same information:

mysql -u root -p -e 'show databases;'

GUI tools

Since you are new to MySQL, it is better to use GUI tools. Please refer the previous article about “GUI Tools for managing MySQL databases server“.

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
51 comments… add one
  • siteXmedia Apr 5, 2015 @ 13:45

    Sorry to be negative, your end comment:

    “Since you are new to MySQL, it is better to use GUI tools”

    I have to disagree with, it is far better and quicker to learn to use the shell commands to do server admin, especially if doing many actions, like creating many databases or importing large amounts of data.

    But phpmyadmin is a great tool if you are working in the gui enviroment and want to make an adjustment for one off changes.I have not tried your other suggestion, but will now

    And as a positive I would like to say a big thanks to all the help I have got from your pages. On a search to resolve a problem I will always click the cyberciti link first.

    Thanks again

  • Nabtron Oct 20, 2015 @ 3:41

    Thanks bro :) it was really useful!

  • neelakanth Oct 26, 2015 @ 4:27

    1. Consider the following relations of medical consultation centre:
    FACULTY (F_id, F-name, F-designation).
    PATIENT (P_id, P_name, p_address, date_of_ registration).
    CONSULTATION DATE (C_date, F_id, P_id).
    Create tables for above relations considering suitable data types and constraints. Insert 5
    appropriate tuples in the tables.
    Write the SQL statements for the following queries.
    1. Generate list of patients and their consultation detail.
    2. Find patients consulted by specific faculty.
    3. Find the details of the entire faculty whose designation is a senior doctor and have
    consultation date next month.
    4. Find the patient whose consultation date is today along with the concerned faculty
    detail.

  • vasant Nov 6, 2015 @ 18:00

    thanks
    helped me a lot

  • Rabnawaz Jan 12, 2016 @ 12:19

    Thank you…

  • david Feb 27, 2016 @ 17:35

    Your one liner sample is wrong should be

    mysql -u root -p -e ‘show databases;’

    • 🐧 Vivek Gite Feb 27, 2016 @ 20:29

      Thanks for the heads up. The faq has been updated.

  • Raymond Wachaga Mwaura Nov 1, 2016 @ 22:10

    Thanks for this article! Expand on it if you can and show us even more commands for us to experiment with.

  • faustina Jan 12, 2017 @ 9:39

    anyone knows about VIEW on database ?

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.