How to use the MySQL command line

Source: Internet
Author: User

How to use the MySQL command line

Login MySQL

To play cmd command terminal, if you have added MySQL environment variables, you can directly use the command

Mysql-uroot

Direct return, followed by prompts to enter the password,

If the MySQL environment variable is not added, you can switch to the bin directory in the MySQL installation directory, and then use

Mysq-uroot

You can also manually add environment variables to MySQL. Here is not how to add the environment variable method

After the password is entered correctly, the Welcome to the MySQL monitor appears. Commands End With; The words "or g ...",

The "mysql>" character prefix appears on the command line. Now you can use the command to manipulate MySQL. There has been no such experience, the original saw someone else in the command line in the knock, a pass of worship, think that this person is very cow, now you can also make a pass worship.

All the commands in MySQL are ";" Or G is a terminator.

New Database

After creating the new database, let's set the character set first

Mysql>set NAMES UTF8;

And then create the database

Mysql>create DATABASE Lesson

Show all databases

Mysql>show DATABASES;

Working with databases

Mysql>use database name;

Create a new table

Mysql>create TABLE Study (

ID int (one) unsigned not NULL auto_increment COMMENT ' student ID number ',

Username varchar not NULL DEFAULT ' COMMENT ' student name ',

Class tinyint (3) unsigned not NULL,

Sex enum (' Male ', ' female ', ' confidential ') CHARACTER SET UTF8 COLLATE utf8_general_ci not NULL DEFAULT ' confidential ' COMMENT ' sex ',

Addtime Int (a) not NULL DEFAULT ' 0 ',

PRIMARY KEY (ID)

) Engine=innodb COMMENT = ' student table ';

Show All Tables

Mysql>show TABLES;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.