MySQL is based on the use

Source: Internet
Author: User
Tags flush

1 login mysql-uroot-p123;

2 Viewing users select User ();

3 Exit Quit/exit/\q

4 View Help information for the create user;

5 Create an Account

Create user ' Egon ' @ ' 192.168.32.* ' identified by ' 123 ';

Create user ' Egon ' @ ' 192.168.32.3 ' identified by ' 123 ';

Create user ' Egon ' @ '% ' identified by ' 123 ';

6 Licensing

Grant all privileges;

Grant all on db1.t1 to ' Egon ' @ '% ';

Grant all on * * to ' egon ' @ '% ';

Flush privileges;

Create an account and authorize

Grant all on * * to ' Alex ' @ ' percent ' identified by ' 123 '

Flush privileges;

7 Remote connection to MySQL

Mysql-uegon-p123-h 192.168.11.55;

8 View all databases

show databases;

Action Library (folder)

-Increase

Create Database db1 charset UTF8;

——-Check

show databases;

Show CREATE Database db1;

-----change

ALTER DATABASE DB1 CharSet GBK;

------Delete

Drop database db1;

Action table (file)

Switch to a library (folder)

   Use DB1;

Select Database (); #查看当前所在的库

----Increase CReate table t1 (id int,name char (TEN), age int) Egine=innodb default charset UTF8; #最后一个字段一定不要加逗号

----Check

Show tables;

Show CREATE table T1;

Desc T1; #查看表结构

----change

ALTER TABLE T1 CHARSET GBK;

ALTER TABLE t1 add sex char;

ALTER TABLE t1 drop sex;

ALTER TABLE t1 modify sex char (6);

ALTER TABLE t1 change sex sex char (6);

----Delete the drop table table88;

Operation Record

----Increase

Insert into DB1.T1 (id,name,age,sex) values

(1, ' egon1 ', ' Male '),

(2, ' egon2,87, ' male '),

(3, ' egon3,45, ' male '),

(4, ' egon4,34, ' male ');

Insert Intl Db1.t1 (Id,name) VALUES (5, ' egon5 ');

----Check

Select Name,id from Db1.t1;

SELECT * from Db1.t1;

-----change

Update db1.t1 set name= ' EGON4 ';

Update db1.t1 set name= ' SBCDD ' where id=5;

Update db1.t1 set name= ' aaaa ' where sex= ' male ';

----Delete

Delete from Db1.t1; #仅仅只有删除记录的效果, there is no function to reset the table to its original state

Truncate DB1.T1; # empty + Reset

Deflete from db1.t1 where id = 3;

Delete from db1.t1 where name= ' dddd ';

Self-Increment ID

CREATE TABLE t1 (ID int not null unique Autl_increment,name char (4)); #自增必需要加括号里的字段

Insert into DB1.T1 (name) values

(' Egon1 '),

(' Egon2 '),

(' Egon3 '),

(' Geon4 ');

  

MySQL is based on the use

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.