Linux

Question

How to list databases from Linux command list?

By samueltarcin9999 ·
I have a mariadb database and I want to list existing databases from the linux command line.
Thread display: Collapse - | Expand +

All Answers

Collapse -

DATABASE LINUX COMMAND

by jackdanielsking2 In reply to How to list databases fro ...

When administering MySQL database servers, one of the most common tasks you’ll have to do is to get familiar with the environment. This involves tasks such as listing databases that reside on the server, displaying the tables of a particular database, or getting information about user accounts and their privileges.

This tutorial explains how to show all databases in a MySQL or MariaDB server through the command line.

The command will print a list of all the databases for which the user has some kind of a privilege granted to . The output will be similar to this:

Show MySQL Databases
The most common way to get a list of the MySQL databases is by using the MySQL client to connect to the MySQL server and run the SHOW DATABASES command.
Another command that you can use to list the databases is SHOW SCHEMAS which is a synonym for the SHOW DATABASES command
Show All MySQL Databases
To list all the databases on the MySQL server you’ll need to login as a user that can access all databases, by default that is the MySQL root user or set a global SHOW DATABASES privilege.

Log in a MySQL root user:
The LIKE clause can be used to filter the output of the SHOW DATABASES command according to a specific pattern
For example, the following statement will return all databases which names starts with ‘open’:
If you want to make a more complex search you query the schemata table from the information_schema database which contains information about all databases.

The following statement will give you a list of all databases that starts with either “open” or “word”
Show MySQL Databases from the Command Line
To get a list of the databases without logging in to the MySQL shell you can use either the mysql command with the -e option which stands for execute or the mysqlshow that displays databases and tables information.

This is especially usefully when you want to work with your MySQL databases using shell scripts.

Run the following command on your terminal to show a list of all databases:


Access the MySQL server using the following command and enter your MySQL user password when prompted

Conclusion
You have learned how to get a list of all databases in your MySQL server.

Feel free to leave a comment if you have any questions.

Collapse -

How to list databases from Linux command list?

by rvkanth1996 In reply to How to list databases fro ...

The most common way to get a list of MySQL databases is to use the MySQL client to connect to the MySQL server and run the SHOW DATABASES command. If you have not set a password for the MySQL user, you can omit the -p option.

Related Discussions

Related Forums