Bootstrap FreeKB - mySQL / MariaDB - use database
mySQL / MariaDB - use database

Updated:   |  mySQL / MariaDB articles

The use <database name> command is used, as the name suggests, to use a mySQL or MariaDB databases. 

Before you can use a database, you will first need to log into your MariaDB or mySQL server or configure passwordless authentication and then use the -e command line option.

Use the show databases command to view the databases.

show databases;


Something like this should be returned.

| Database           |
| information_schema |
| db001              |
| mysql              |
| performance_schema |


The use <database name> command is used to use a certain database. In this example, the database named db001 will be used.

use db001;


Then you can do something in the database, such as listing the tables in the database.

show tables;


Something like this should be returned.

| Tables_in_db001  |
| table001         |
| table002         |
| table003         |


Or, the "use <database name>" command can often be ignored by including the database name is some other command. For example, here is how you could list the tables in the database named db001 without using the "use <database name>" command.

show db001.tables;


Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee


Add a Comment

Please enter 07a658 in the box below so that we can be sure you are a human.