To connect to MySQL from the command line, follow these steps:
- Log in to your A2 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 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.
When you run a command at the mysql> prompt, you may receive a warning message if MySQL encounters a problem. For example, you may run a query and receive a message that resembles the following:
Query OK, 0 rows affected, 1 warning (0.04 sec).
To view the complete warning message, type the following command:
SHOW WARNINGS;
More Information
For more information about the mysql command line program, please visit http://dev.mysql.com/doc/refman/5.1/en/mysql.html.
Comments
Post a Comment