How To List MySQL/MariaDB Databases

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/list-mysqlmariadb-databases/
PINTEREST
PINTEREST
INSTAGRAM

I have some MySQL databases. I have no previous experience about MySQL. How can list existing databases with bash?MySQL and MariaDB are using same code base and tools. So we can use following instructions to list MariaDB too.

Check Database Service

First be sure MySQL/MariaDB service is running

Check Database Service
Check Database Service

As we can see from systemctl output the database service is working properly.

Login To MySQL Interactive Shell

In order to list databases we need to connect and login MySQL interactive shell. We will use mysql tool by providing the user root

Login To MySQL Interactive Shell
Login To MySQL Interactive Shell

Now we will use show databases command to list existing databases. ; is important which means end of the command.

List Databases
List Databases

We cab see that there is 5 databases in this MySQL Server.

List Without Entering MySQL Shell

Entering MySQL database server and running show database command may a trivial task. We can directly run show database command from the Linux bash shell like below by using -e option.

List Without Entering MySQL Shell
List Without Entering MySQL Shell

List Without Entering MySQL Shell From Remote Database Server

If we want to list databases from a remote database server we need to provide the remote system host name or IP address. In this example we will use -h option which is short form of host. We will connect remote server `192.168.142.144

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/list-mysqlmariadb-databases/
PINTEREST
PINTEREST
INSTAGRAM
LEARN MORE  How To Access MySQL Database From Java Applications?