MariaDB – How to Change Database in SSH

Change database

Working with MariaDB is in many ways the same as working with MySQL. You will be using a lot of the same commands and operations. As you may already know from working in MySQL, you must select a database to work with in order to perform various functions. Of course, you cannot work on multiple databases at once, you must select which database at a time with which you will be working. So in this article, you will see how to select and change an active database in MariaDB.

How to Change Databases on the MariaDB Command Line

First, you must log into your server using SSH. Then, as usual, log into the MariaDB command prompt:

mysql -u <username> -p

Replace <username> with your actual username and provide your password.

log into your server using SSH

In case you can’t remember the specific name of the database you want to use, you can always show databases with this command:

SHOW DATABASES;
show databases command

You can both select and switch between databases using the “use” command, as seen below:

USE <databasename>;

At any point during your work you can “show” all databases with SHOW DATABASES; and select a different database with USE <databasename>; — of course, substituting <databasename> with the actual name of the database you want to use.

How To Exit MariaDB Command Line

Now that you have completed your work on the command line, you will want to exit the MariaDB command prompt and return to your standard shell prompt. For most terminal emulators, you can exit the MariaDB command line by pressing Ctrl-D on your keyboard or type exit in lower case and hit <Return> or <Enter>.

AC
Arnel Custodio Content Writer I

More Articles by Arnel

Was this article helpful? Join the conversation!

Questions about our MailChannels Deployment? We have answers and are here to help!Learn More
+