I. MySQL installation and managementThe tar unpacking command
Tar xvf package file name
Tar-packed commands
tar cvf file names to package
rpm Unload Command
RPM-E Package Name
RPM-E Package name--nodeps forcibly unloaded, does not check package dependencies
RPM installation Package Command
RPM-IVH Package Name
two. Character Set
1, the first operating system's character set is UTF8
View operating system character Set commands
locale
2. When creating the database, use character set UTF8; Specify the character set as UTF8
3. Setting the MySQL client character set
SET NAMES UTF8;
4, CRT set to UTF8
three.SQL language
in SQL language, strings are quoted in single quotes.
search for students older than 21 years old
SELECT * FROM table1 WHERE age >;
Query C + + class all students
SELECT * FROM table1 WHERE class = ' C + + class ';
Query C + + class all students and older than
SELECT * FROM table1 WHERE class = ' C + + class ' and ' Age > ';
Find all the students surnamed Wang
SELECT * FROM table1 WHERE name is like ' Wang% ';
Add PATH environment variable in Windows
C:\mysql\lib; C:\mysql\bin
MySQL port number 3306, to join 3306 ports in Linux to the list of trusted ports in the firewall
distinct represents filtering for duplicate values
aggregation functions are often used in conjunction with group by words.
find the oldest student's name in the old teacher's class
Select A.name from table1 A, table3 b where A.class = B.class and B.teacher = ' Ms. Cang '
and a.age = (select Max (c.age) from table1 C, table3 d where c.class = D.class and D.teacher = ' Cang
teacher ');
in the SELECT statement, which field is used in the Where query, the field must be indexed
queries for unique indexes are more efficient than normal indexes
the primary KEY (ID) statement is equivalent to establishing a unique index for the ID field when the table is established
four. Operational Database
Login
mysql-u root-p
how to log in to remote MySQL server
mysql-h IP address-u user name-P
Working with Databases
Use db1;
Set character sets
set names UTF8;
View Table Structure
desc table1;
Insert Data:
INSERT into table1 (name, sex, Age, Class) VALUES (' Zhang San ', ' Male ', 24, ' 0802 classes ');
Query data:
SELECT * FROM table1;
Execute SQL Script
Source My.sql--my.sql-------------------
Insert INTO table1 (name, sex, Age, Class) VALUES (' Xiao Wang ', ' Female ', ' C + + class '); insert into table1 (name, sex, Age, Class) VALUE S (' Xiao Li ', ' Male ', ' C + + class '), insert into table1 (name, sex, Age, Class) VALUES (' Xiao Zhang ', ' Male ', ', ' Java class '); insert into table1 (n Ame, sex, age, Class) VALUES (' pock ', ' female ', ' C + + class '), INSERT into table1 (name, sex, age, Class) values (' Zhang's grandfather ', ' Male ', 24, ' PHP class '); INSERT into table1 (name, sex, Age, Class) VALUES (' Little Dragon Girl ', ' female ', ', ' C + + class ');
C + + Institute (+) MySQL database programming--Introduction to development/sql statements