Skip to content
Home ยป How to Display All Databases Created by the User in MariaDB?

How to Display All Databases Created by the User in MariaDB?

  • by

By default, in MariaDB, 4 databases are automatically created by the database system, namely information_schema, mysql, performance_schema, and sys. But I just want to display a database created by the user and not the default system databases.

 

Problem

How to display all databases created by the user in MariaDB?

 

Solution

If you use the show databases command after you access successfully accessing MariaDB, it will display all databases created by the user and default system databases, as shown below:

Display all databases

 

If you want to list only User-Created Databases, you can use a query as below:

SELECT SCHEMA_NAME
FROM information_schema.SCHEMATA
WHERE SCHEMA_NAME NOT IN ('information_schema','mysql','performance_schema','sys');

 

and it will display like the image below:

Display only User-Created Databases

 

Note

If you want to run the Linux command to display all databases created by the user only, use the command below:

mysql -u root -p -e "SELECT SCHEMA_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME NOT IN ('information_schema','mysql','performance_schema','sys');"

 

And you will see the result like the image below:

Display only User-Created Databases using the Linux command

 

References

stackoverflow.com
kinsta.com

image_pdfimage_print
Visited 24 times, 1 visit(s) today
Tags:

Leave a Reply

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