MySQL Build database build table Build user

Source: Internet
Author: User

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

Related Article

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.