In MySQL, you can use SHOW DATABASES statement to view or display the database user privileges within the current range. View database syntax is:
SHOW DATABASES [LIKE 'database name'];
Syntax is as follows:
- LIKE clause is optional, used to match the specified database name. LIKE clauses can be a partial match may be an exact match.
- Database name from the single quotes
' '
surrounded.
Example 1: View all databases
List all current user database can be viewed:
mysql> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sakila | | sys | | world | +--------------------+ 6 row in set (0.22 sec)
Example 2: Create and view database
First create a database called test_db:
mysql> CREATE DATABASE test_db;
Query OK, 1 row affected (0.12 sec)
Then use the SHOW DATABASES statement to display the name of the database within the purview of all, as shown below:
mysql> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sakila |