EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Software Development Software Development Tutorials MariaDB Tutorial MariaDB show databases
 

MariaDB show databases

Updated April 17, 2023

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.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Syntax

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

We hope that this EDUCBA information on “MariaDB show databases” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

  1. MariaDB Commands
  2. MariaDB UPDATE
  3. MariaDB AUTO_INCREMENT
  4. MariaDB Foreign Key

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

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

EDUCBA

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

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

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

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

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

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW