1. Create a database
Create Database School;
2. Using the database
Use school;
3. Create a user
Create user [email protected] identified by ' Jame ';
4. Authorized users (Note that this is the use of * Oh, you can speak school also replace the * number)
Grant Select,update,insert,create on school.* to [email protected] identified by ' J Ame ';
5. Cancellation of authorization (now understand why it is useless to knock privilege directly?) )
Revoke select,update,insert,create on school.* from [email protected];
6. Create a table
CREATE TABLE students (s_name varchar) not null,age int (3), sex char (1), Heig HT int,s_no varchar (a) Not null,primary key (S_No));
7. Modify the table name
ALTER TABLE students rename to student;
8. Modifying columns
ALTER TABLE students change s_name name varchar (a) not null;
9. Add columns
ALTER TABLE student Add class varchar (20);
10. Delete Columns
ALTER TABLE student drop column class;
11. Delete a table
drop table student;
12. Delete a user
Drop user Jame;
13. Deleting a database
Drop Database School;
View table structure methods for a database DESC students; or describe students; Another: The MySQL user cannot switch user after entering the console, can only exit the terminal first, and then reconnect.
MySQL Build database build table Build user