This article will show you how to use the mysql program to connect to MySQL from the command line. You can use the mysql program to quickly and easily access your databases.
To connect to MySQL from the command line, follow these steps:
- Log in to your Hostginger Hosting 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.
- To view a list of commands, type help at the mysql> prompt.
- To exit the mysql program, type \q at the mysql> prompt