# Connecting to MySQL from the command line

> Connect to your MySQL databases over SSH with the mysql command-line program and run basic commands to work with your data.

Source: https://helpcenter.ruachost.com/developers/databases/connecting-to-mysql-from-the-command-line/

**Connecting to MySQL from the command line**\
This article explains how to connect to MySQL using the `mysql` command-line program, which allows direct access to your databases.

## Connecting to MySQL

1. Log in to your account using SSH.
2. At the command line, type the following command, replacing `username` with your MySQL username:

   ```
   mysql -u username -p
   ```

3. At the Enter Password prompt, type your password. When correct, the `mysql>` prompt appears.

**Viewing databases**\
To list all databases, type:

```
show databases;
```

**Note:** Don’t forget the semicolon at the end of the statement.

**Accessing a specific database**\
To select a database, type:

```
use dbname;
```

**Note:** Don’t forget the semicolon.

## Using MySQL commands

- To view available MySQL commands, type `help` at the `mysql>` prompt.
- To exit the program, type `\q`.

**Tip**\
If MySQL encounters a problem, you may see a warning like:

```
Query OK, 0 rows affected, 1 warning (0.04 sec).
```

To see full warning details, type:

```
SHOW WARNINGS;
```

**More information**\
For details about the `mysql` command-line program, visit [MySQL documentation](http://dev.mysql.com/doc/refman/5.1/en/mysql.html).
