Friday, 13 November 2020

SQL: print all the databases

‘show databases’ command is used to print all the available databases.

 

Step 1: Connect to mysql server by executing the command 'mysql -u root -p'.

bash-3.2$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 43
Server version: 8.0.21 Homebrew

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

 

Step 2: Execute the command ‘show databases’ to get all the databases.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| demo               |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

mysql>

 


 

Previous                                                    Next                                                    Home

No comments:

Post a Comment