MariaDB – How to Change Database in SSH

If you want to change between databases in MariaDB using SSH, it will depend on the user name that you’re using when you’re logged into the command line. The following tutorial will show you how to change the database in command line. Note that some user names may be assigned to multiple databases.

  1. Login to SSH.
  2. Login to MySQL (MariaDB) using the database user that you know is assigned to the database you’re trying to view. Use the following command:
    MariaDB [(none)]> mysql -u username -p

    You will notice the following screen if you successfully login. Note that you can see that you’re using MariaDB at this point.

    Login to the mysql command line

  3. If you don’t know what databases are assigned to the user that you selected, then you can view the databases that have been assigned to that user..
    MariaDB [(none)]> show databases;

    You will see a list of databases assigned to that user.

    show the databases assigned to the user

  4. You will need to select the database by using the following command:
    MariaDB [(none)]> use databasename;

    Select the database you want to see

At this point you will be working with the database that you have selected based on the user name you are using. If you want to change databases, you may need to change databases. You can use the exit command to logout. Or if you can use the same user name, you can repeate the use command to select a different database.

Arnel Custodio Technical Writer; WordPress Contributor & Volunteer

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!