Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using MySQL Command Line Client

I'm new in creating databases in MySQL. I've done creating tables in MySQL Workbench. Now I want to check the databases I've created using the MySQL Command Line Client. How should I do this? What should I type in the Command Line? Please help. Thanks.

like image 863
sean Avatar asked Jun 21 '11 02:06

sean


People also ask

How do I run MySQL client from command-line?

Launch the MySQL Command-Line Client. To launch the client, enter the following command in a Command Prompt window: mysql -u root -p . The -p option is needed only if a root password is defined for MySQL. Enter the password when prompted.

What is the use of MySQL command-line client?

MySQL client is a common name for tools that are designed to connect to MySQL Server. Client programs are used to send commands or queries to the server and allow managing data in the databases stored on the server.

Is MySQL Shell and MySQL command-line client same?

MySQL Shell is an advanced command-line client and code editor for MySQL. In addition to SQL, MySQL Shell also offers scripting capabilities for JavaScript and Python. For information about using MySQL Shell, see MySQL Shell 8.0.


1 Answers

To see all databases:

show databases;

To switch to a specific database (note that the trailing ; is optional here):

use databasename

To see the tables within the current database:

show tables;

To see the create table statement for a specific table:

show create table tablename;

To see other misc info about a specific table:

describe tablename;

Additionally, all kinds of other interesting meta information is contained within the information_schema database. You can use information_schema and explore those tables for a wealth of information about your databases.

Another useful trick in the MySQL command line console is to terminate your queries with \G instead of ;. This causes output to be displayed all vertically rather than in a table, which is useful for tables that are wider than your screen display.

like image 167
Asaph Avatar answered Oct 28 '22 18:10

Asaph