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;