Connect to a database via SSH

 

Overview

You can connect to your MySQL database over SSH from your DreamHost webserver or from your home computer. The instructions below explain how to log in to your DreamHost webserver to connect.

Prerequisites

This article assumes you have created a shell user and are able to log into your server via SSH.

How do I connect from a shell account?

Log into your MySQL database using your database credentials. View the Finding your database credentials article for instructions. You can also find these in the panel under MySQL Databases.

  1. Obtain your database credentials.

    It's not possible to localhost to connect to your database, as DreamHost's MySQL servers are on a separate database server.

  2. Log into your server via SSH.
  3. Run the following command.
    [server]$ mysql -h hostname -u user -p database
  4. Enter your password when prompted.

Once logged in, your command prompt will change to the following:

mysql>

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?