
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Get a list of MySQL databases and version?
To get a list of MySQL databases, following is the syntax -
show databases;
To get the server version, you can use the below syntax -
select version();
Let us implement the above syntax to get a list of MySQL databases and version -
mysql> show databases;
This will produce the following output displaying all the databases -
+---------------------------+ | Database | +---------------------------+ | bothinnodbandmyisam | | business | | commandline | | customer-tracker | | customer_tracker_database | | customertracker | | database1 | | databasesample | | demo | | education | | hb_student_tracker | | hello | | information_schema | | instant_app | | javadatabase2 | | javasampledatabase | | login | | mybusiness | | mydatabase | | mysql | | onetomanyrelationship | | onlinebookstore | | performance_schema | | rdb | | sample | | sampledatabase | | schemasample | | slotgame | | sys | | test | | test3 | | tracker | | universitydatabase | | web | | web_tracker | | webtracker | +---------------------------+ 36 rows in set (0.00 sec)
Following is the query to get version -
mysql> select version();
This will produce the following output -
+-----------+ | version() | +-----------+ | 8.0.12 | +-----------+ 1 row in set (0.00 sec)
- Related Articles
- Return list of databases in MySQL?
- How can I get a list of databases and collections on a MongoDB server?
- How to get the list of all databases using JDBC?
- List of non-empty tables in all your MySQL databases?
- How to get the list of all the MongoDB databases using java?
- How to list databases vertically in MySQL command line?
- How can we display a list of currently existing MySQL databases on the server?
- What is the synonym statement of SHOW DATABASES with the help of which we can see the list of MySQL databases?
- How to get a list of MySQL views?
- How to get a list of MySQL indexes?
- Get a list of Constraints from MySQL Database?
- Get MongoDB Databases in a JavaScript Array?
- How to get a list of MySQL user accounts?
- Get a list of Foreign Key constraints in MySQL
- How to get a list of MySQL user hosts?

Advertisements