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 in order to perform various functions. Of course, you cannot work on multiple databases at once, you must select which database with which you will be working. So in this article, we’ll show you how to change an active database, or switch databases, 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.

mariadb change db login to mysql

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

SHOW DATABASES;
mariadb change db show databases

You can both select and switch between using the “use” command:

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

As a writer for InMotion Hosting, Arnel has always aimed to share helpful information and provide knowledge that will help solve problems and aid in achieving goals. He's also been active with WordPress local community groups and events since 2004.

More Articles by Arnel

Was this article helpful? Let us know!