Enter mysql-uroot-p123456 (-u account-p password) on the command line to log in to the MySQL server
1. Set the MySQL password
Set password for ' root ' @ ' localhost ' = password (' 123456 ');
--All SQL statements are terminated with a semicolon '; '
2. See what databases the current server has
show databases;
3. Switch the Working database (use library name)
Use test;
4. Create a new database library name
Create DATABASE company;
5. Discard Database Library names
Drop Database Company;
6. See what tables are in the current database
Show tables;
7. Import the Execute SQL script
SOURCE D;/mywork/mysql/company.sql;
8. View all the data in the table (SELECT * From ... Table name)
SELECT * FROM Employees;
9. View the table structure (because it is commonly used so you can omit Ribe) (Country table name)
Desc[ribe] country;
10. Creating a table (create TABLE table name)
CREATE TABLE Customer (
ID int,
Name varchar (20),
Age int,
Birthday Date
);
11. Insert record (table name)
INSERT INTO Customer (
Id
Name
Age
Birthday
) VALUES (
1,
' Zhang San ',
30,
' 1994-11-2 '
);
12. Update to record all matching data
Update
Customer
Set
id = 1,
Age = 40;
(Update qualified Records)
Update
Customer
Set
id = 2,
Age = 40
where
id = 2;
13. Deleting records
Delete from
Customer
where
id = 3;
CRUD--Adding and deleting changes
Query Select
inserting INSERT INTO
Updating update
Remove DELETE from
Hierarchy of data management
| --Database 1 (directory)
| --Table 1
|--Record 1
|--Record 2
......
| --Table 2
......
| --Database 2 (directory)
Rmdb-relational database management system
The alias for the column, using the AS keyword, and you can omit
SELECT
Code as C,
Population p
From
Country;
Select
Code
Population
From
Country;
Simple MySQL common commands