How do I connect to my database via SSH?

Connecting from a shell account

  1. Log in to your DreamHost account from your local computer.
    [local]$ ssh -l USERNAME
    • Replace 'example' with your domain name.
  2. Log in to your MySQL database. You can find the necessary hostname, username, password, and database names in the Control Panel under (Panel > 'Goodies' > 'MySQL Databases').
  3. Make sure to use your actual credentials for the following variables:
    • - Your mysql hostname URL
    • DBuser - Your database username
    • DBpassword - Your database username's password
    • DB - Your database name
    [server]$ mysql -h -u DBuser -p DB
  4. Optionally, include your password in the command (do not include a space after "-p").
    [server]$ mysql -h -u DBuser -pDBpassword DB

You cannot use "localhost" to connect to your database, as DreamHost's MySQL servers are separate from the regular web site servers.

See also

Did this article answer your questions?

Article last updated PST.