How Can We Help?
How to connect to MySQL from the command line
This article describes how to connect to MySQL from the command line using the mysql program. You can use the mysql program as a quick and easy way to access your databases directly.
Connecting to MySQL from the Command Line
To connect to MySQL from the command line, follow these steps:
- Log in to your XauZit Cloud account using SSH.
- At the command line, type the following command, replacing username with your username:
mysql -u username -p
- At the Enter Password prompt, type your password. When you type the correct password, the mysql> prompt appears.
- To display a list of databases, type the following command at the mysql> prompt:
show databases;
To access a specific database, type the following command at the mysql> prompt, replacing dbname with the name of the database that you want to access:
use dbname;
- After you access a database, you can run SQL queries, list tables, and so on. Additionally:
- To view a list of MySQL commands, type help at the mysql> prompt.
- To exit the mysql program, type \q at the mysql> prompt.
More Information
- For more information about the mysql command line program, please visit http://dev.mysql.com/doc/refman/5.1/en/mysql.html.

