Now to introduce the MySQL command line, from the establishment of the database to the table data delete the whole process, I hope to help.
Login MySQL
Play cmd command terminal, if you have added a MySQL environment variable, you can directly use the command Mysql-uroot direct return, and then prompted 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 the Mysq-uroot
You can also manually add environment variables to MySQL.
Here's how to add an environment variable so that you can run MySQL on the cmd command line.
Download the latest version of the MySQL software, the MySQL installation to the system directory, record the current installation directory;
such as: Install MySQL to c:/program files/mysql directory
Step: 1, open the Win7 system--computer--System Properties
2, Click the environment variable, enter the environment variable settings menu
3. Select "Path" in the system variable and enter at the beginning of the path value :C:\program files\mysql\bin, save exit
4. Start-Search--cmd, open CMD command line, enter mysql-u username-P login MySQL
Note:mysql-u Username: Username enter MySQL username
-P: indicates that you want to enter a password
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 as a terminator.
New Database
After creating the new database, let's set the character set:mysql>set NAMES UTF8;
Then create the database:mysql>create DB Lesson
Display all databases:mysql>show DATABASES;
Use database: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 () NO T null DEFAULT ' COMMENT ' student name ',
class tinyint (3) unsigned not NULL,
sex enum (' Male ', ' female ', ' confidential ') Charactersetutf8coll Ateutf8_general_cinotnulldefault ' confidential ' COMMENT ' sex ',
addtime Int (a) not NULL DEFAULT ' 0 ',
PRIMARY KEY (ID)
) Engine=innodb comment= ' student table ';
Show All tables:mysql>show tables;
To modify the name of a table:
Mysql>renametable study to Study_new;
Or
mysql>altertablestudy_newrenametostudy;
Display field information: ShowCOLUMNS from study or describe study
Inserting data:Mysql>insert into study (username,class,sex) VALUES (' Xiao Wang ', 1, ' Male '), (' Small Four ', 2, ' female ');
Query data (make CONCAT function splice data):mysql> SELECT Username,concat (class, ' class '), sex from study;
Delete data:mysql>delete from study WHERE id=1;
Delete datasheet:drop table study;
Delete database:mysql> drop db lesson;
The above describes how to operate the MySQL command line, as well as configure environment variables, I hope to help you learn.