EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login
Home Software Development Software Development Tutorials MariaDB Tutorial MariaDB show databases
Secondary Sidebar
MariaDB Tutorial
  • MariaDB
    • MariaDB Versions
    • MariaDB? list users
    • MariaDB Commands
    • MariaDB odbc
    • MariaDB Workbench
    • MariaDB for windows
    • MariaDB Server
    • MariaDB? Data Types
    • MariaDB? boolean
    • MariaDB phpMyAdmin
    • MariaDB Mysqldump
    • MariaDB Java Connector
    • MariaDB insert
    • MariaDB UPDATE
    • MariaDB? rename column
    • MariaDB AUTO_INCREMENT
    • MariaDB Timezone
    • MariaDB GROUP_CONCAT
    • MariaDB wait_timeout
    • MariaDB MaxScale
    • MariaDB? with
    • MariaDB GUI
    • MariaDB? create?table
    • MariaDB? SHOW TABLES
    • MariaDB alter table
    • MariaDB List Tables
    • MariaDB JSON Functions
    • MariaDB Foreign Key
    • MariaDB? trigger
    • MariaDB Grant All Privileges
    • MariaDB Select Database
    • MariaDB? create database
    • MariaDB Delete Database
    • MariaDB Join
    • MariaDB JSON
    • MariaDB? show databases
    • MariaDB List Databases
    • MariaDB Functions
    • MariaDB? TIMESTAMP
    • MariaDB create user
    • MariaDB add user
    • MariaDB Max Connections
    • MariaDB show users
    • MariaDB Delete User
    • MariaDB? change user password
    • MariaDB? change root password
    • MariaDB reset root password
    • MariaDB IF
    • MariaDB bind-address
    • MariaDB Transaction
    • MariaDB Cluster
    • MariaDB Logs
    • MariaDB Encryption
    • MariaDB? backup
    • MariaDB Replication
    • MariaDB max_allowed_packet
    • MariaDB? performance tuning
    • MariaDB export database
    • MariaDB? import SQL

MariaDB show databases

MariaDB show databases

Introduction to MariaDB show databases

MariaDB provides a show database command to the user in which that show database command lists all databases on the MariaDB server. When we administer MariaDB database servers, one of the most common tasks is that we need to get familiar with the MariaDB server environment. We start with the listing database on the server.  Show database command is useful when we are working with MariaDB to manage the database through the command line.  To access databases, we must log in on the MariaDB server and list all databases from the MariaDB server. We can also use different clauses to show database commands.

All in One Software Development Bundle(600+ Courses, 50+ projects)
Python TutorialC SharpJavaJavaScript
C Plus PlusSoftware TestingSQLKali Linux
Price
View Courses
600+ Online Courses | 50+ projects | 3000+ Hours | Verifiable Certificates | Lifetime Access
4.6 (86,130 ratings)

Syntax

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

show database;

Explanation

In the above syntax, we use the show database command to list all databases on the MariaDB server. This is a very simple syntax we used to show databases.

How to show databases in MariaDB using various ways?

Let’s see different ways to show databases in MariaDB as below.

To list databases on the MariaDB server, we need to login to MariaDB then we can use different commands to list databases.

Firstly, we can directly list all databases on the MariaDB server, in which we can use the show database command to list all databases on the MariaDB server. This command directly fetches all available databases from the MariaDB server.

The second way we can use the show schema command to list all databases on the MariaDB server. The show schemas are a synonym for the show databases.

Thirdly, we use like and where clauses to list databases as patterns or words on the MariaDB server.

In MariaDB, we can see only those databases with which we have some kind of privilege; otherwise, we can use global show database privilege. We can also list the database on the MariaDB server by using the MySQL show command.

The return result by show database depends on directories in the data directory, depending on how MariaDB implements databases.

Examples

Let’s see a different example of show database commands as below.

show databases;

Explanation

In the above example, we use the show database command to list all currently available databases on the MariaDB server. The final output of the above query we illustrate by using the following snapshot.

MariaDB show databases output 1

Now suppose the user created a new database name as the country by using the following statement as below.

create database country;

Explanation

With the help of the above statement, we created the database name as the country, and we can do this database by using the show database command; after the execution of the above statement, the result is query is ok, and if we need to see the created database at that time we run show databases command. The final output of the show databases queries we illustrate by using the following snapshot.

MariaDB show databases output 2

Example

show schemas;

Explanation

See in this example; we also got the same results that mean we list all databases on the MariaDB server by using the show schemas command as shown in the above statement. The final output of the show databases queries we illustrate by using the following snapshot.

MariaDB show databases output 3

Example

SHOW DATABASES LIKE 's%';

Explanation

In the above example, we use like clause with show databases command, suppose user need to list all databases those name start with s character at that time we can use the above statement. So in this way, we can list all databases as per our requirement. The final output of the show databases queries we illustrate by using the following snapshot.

output 4

We can also use a different way to list databases from the MariaDB server; in the next example, we use a generic query to list all databases as below.

select schema_name as current_Database_name
from information_schema.schemata;

Explanation

See in the above example select clause to fetch schema from information_schema table, in MariaDB information_schema table is used to store database name. In the above statement, we use the current database name as a schema name, as shown in the above statement.

So with the help of the above query, we return all lists of databases on the MariaDB server. The final output of the show databases queries we illustrate by using the following snapshot.

output 5

One more thing with this query we can also use order by clause as per user requirement, so we will get a sorted database list from the MariaDB server.

Example

show databases
where `database` not in
('information_schema',
'performance_schema',
'mysql'
);

Explanation

Sometimes database administrators need to see the user-created database. At that time, we use the above statement; here, we use show databases with where clause and not in the keyword to restrict some entry from the above-mentioned schemas. The final output of the show databases queries we illustrate by using the following snapshot.

output 6

Let’s see another example of where clause as below.

SELECT schema_name
FROM information_schema.schemata
WHERE schema_name LIKE 'sample%' OR
schema_name LIKE 'demo%';

Explanation

In the above example, we use select and where clauses to list specified database names that are mentioned in the condition. In this example, we need to find, or we can say we need to list two database names, such as sample and demo, without using the show database command. So in this example, we use information_schema to match the exact result. The final output of the show databases queries we illustrate by using the following snapshot.

output 7

Suppose users need to see a currently used database, so at that time, we use the below statement.

select database();

Explanation

In the above example, we simply used a select clause to see the currently used database on the MariaDB server. The currently used database is a sample. The final output of the show databases queries we illustrate by using the following snapshot.

output 8

Conclusion – MariaDB show databases

We hope from this article you have understood about the MariaDB show databases. From this article, we have learned the basic syntax of MariaDB show databases, and we also see different examples of MariaDB show databases. From this article, we learned how and when we use MariaDB show databases.

Recommended Articles

This is a guide to MariaDB show databases. Here we discuss the basic syntax of MariaDB show databases and different examples of show databases. You may also have a look at the following articles to learn more –

  1. MariaDB Commands
  2. MariaDB UPDATE
  3. MariaDB AUTO_INCREMENT
  4. MariaDB Foreign Key
Popular Course in this category
SQL Training Program (7 Courses, 8+ Projects)
  7 Online Courses |  8 Hands-on Projects |  73+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course
0 Shares
Share
Tweet
Share
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2022 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

C# Programming, Conditional Constructs, Loops, Arrays, OOPS Concept

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more