Connecting to MySQL from the command line
Ce contenu n’est pas encore disponible dans votre langue.
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
Section titled “Connecting to MySQL”-
Log in to your account using SSH.
-
At the command line, type the following command, replacing
usernamewith your MySQL username:mysql -u username -p -
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
Section titled “Using MySQL commands”- To view available MySQL commands, type
helpat themysql>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.
Cette page vous a-t-elle aidé ?
Merci pour votre retour.