What is the database
Storing data warehouse
1. List the dictionary .... etc. shortcomings are memory: power loss advantages: speed
2. File storage Cons: Slow advantages: it can achieve permanent preservation
The client and server programs is essentially a CS-based structure, final data stored in the server's disk
Why use a database
1. Slow
2. Our program may be distributed in the future on different machines
A single machine performance definitely has an upper limit, if a machine is not able to meet, you can use multiple machines to complete common tasks
Distributed to each server to provide different services, sometimes a business process may involve multiple servers
Benefits: reduce the degree of coupling easy to maintain, Disadvantages: cumbersome communications, disaster recovery cluster of no good
All services provided by the server cluster is exactly the same, its advantages: disaster recovery and strong, easy to expand pluggable
Question: data distributed across different machines how to access the network access?
-
User rights management
-
Multiple clients concurrent access to data to ensure security
Classification database
Divided
1. Relational Databases
There may be associated with a relational database data between the village will help us to maintain this relationship
Disk storage media are usually
Common relational:
mysql
The focus of our study: is the most popular relational database, as well its free, open source, performance
Oracle has now been acquired, for small and medium enterprises
sqlserver
Is Microsoft's, because it can only run on windows platform so development is not ye
oracle sun
The most powerful relational database, primarily in the cluster, and user management, is ideal for large enterprises
db2
IBM's product, the main users of the bundled hardware for enterprise customers, not bad money selling
2. Non-relational databases
Did not help us maintain the relationship between the data,
Memory storage media are usually
Common non-relational:
mongoDB
repeat
memcache
Database Key Concepts
Data (Column) file in a string
Record (Row) files in a row
Table (Table) a file
Library (DataBase) is a folder
DBMS database management system (refers to database software)
The database server is running DBMS computer
Install Database
Using compressed way to install, you can extract to a local
bin store all executable files
Storing data position data
Use simple steps:
There is a server-side down bin mysqld.exe mysql.exe program is a client program
You need to run mysqld.exe
Run client, if double click to run directly into the mode of tourists
The correct way is to run the specified user name and password and other parameters in the terminal
Common parameters -h host name if the machine is negligible
-P specifies the default port 3306 can not write
-u Specifies the user name
-p specify a password
Adding Environment Variables
Registry Services
Registration mysqld --install
Delete sc delete mysql (note the service name is not a file name)
Start Service net start mysql;
Stop service net stop mysql;
Find a process
tasklist | findstr mysqld
Kill the process
taskkill /f /pid 111111
mysql 5.6 administrator password settings
1. know the original password
1.1 Log on to perform an update statement to modify mysql
update user set password = password("123") where host="localhost" and user="root";
Refresh new flush privileges; or restart mysqld
2.2 mysqladmin Gadgets
mysqladmin -uroot -p123 password 321
-p is the original password
2. Do not know the original password
2.1 Delete permissions related files (easily beaten)
2.2 skip Authorization Form
Specify the parameters manually start mysqld
mysqld --skip-grant-tables
update user set password = password("111") where host="localhost" and user="root";
You can restart mysqld
Simple to use
Data must find a file that is kept up table, the table must exist in the library is a folder
The first step should be to create a database to create a table
Library Operation
# Switch databases
use the database name you can not add a semicolon # View all databases Show Databases; Show the Create Databases; # View database details # create a new database the Create Database database name; the Create Database database name of the charset utf8; # specify the encoding # delete database drop database database name; # coding can modify the database into the database folder modification db.opt # the first line is the second line is coded collation own search for a # modify the database name can be edited directly correspond folder name
Naming conventions:
1. not case sensitive
2. Do not use keywords such as, for example, create select .....
3. You can not use pure digital
4. The character combination may generally decline line numbers decline line
Operating table
Table # Create
Create Table table name ( column name Data type column, column name 2 Type 2, ....) charset GBK;
# specified encoding
Create Table table name ( column name Data type column, column name 2 Type 2, ....) charset GBK; # View all the tables in the current database Show the tables; # View table structure desc table name; create table statement # View Show the create the table table name; # delete tables drop the table name; # empty table reconstructed data table TRUNCATE table name; # modified table structure
# Add fields
the ALTER the Table table name add the name of the column data type;
# delete the field
the ALTER the Table table name drop column name;
# modify the data type of
the ALTER the Table table name modify the name of the column new data types;
# modify the column names
the ALTER the Table table name change old the column names new column name of the new type; the name # modify the table of the rename the table the old name to the new name; # coding modify the ALTER the table table name charset utf8;