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

     

  1. 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.

Was dit antwoord nuttig? 0 gebruikers vonden dit artikel nuttig (0 Stemmen)

Powered by WHMCompleteSolution