1. Database
What is the data (Data)
Data records of a transaction descriptor is, the symbol described things may be numbers, text, images, etc., to be described in a computer object, it is necessary to extract the characteristics of things, the composition of one record.
What is the database (DataBase, referred to as DB)
The database is stored data warehouses, but now the warehouse is on a computer storage device, stored in a certain format
Data in the database has a smaller redundancy, higher data independence and extensibility line
What is a database management system (Database Management System, referred to as DBMS)
Database management system is an application to manage data and databases
Database management database is divided into two categories:
Relational Database
And it is linked between the restriction data and
The first step needed to determine the structure of the table when the table is usually a relational database structure, so we use this type of database
Common relational databases have: MySQL, Oracle, sqlite, db2, sql server
Non-relational databases
Data are usually stored in the form of k, v keys
Common are: Redis, MongoDB (document database, very close relationship type of non-relational databases), memcache
Note: In the development of our Python, the most commonly used is the MySQL database
2. acquaintance MySQL
MySQL is a relational database management system, developed by the Swedish company MySQL AB, currently part of Oracle 's products. MySQL is one of the most popular relational database management system, WEB applications, MySQL is the best RDBMS (Relational Database Management System, a relational database management system) applications.
Content classification data in MySQL database
First, a database library consisting of different sizes, and a library of different-sized tables, a table consists of records of different sizes make up
Our internal database can be likened to a computer file system library >>> folder list >>> file records >>> data in the file line by line, called a section of the record header: the first row of the table : Field Name + field type
3.MySQL download and install
mysql installation package provide open source operating system on each of us, including ios, linux, windows.
mysql installation, start-up and basic configuration - linux version (https://www.cnblogs.com/Eva-J/articles/9664401.html)
mysql installation, start-up and basic configuration - mac version (https://www.cnblogs.com/Eva-J/articles/9664401.html)
mysql installation, start-up and basic configuration - windows version (https://www.cnblogs.com/Eva-J/articles/9669675.html)
4. Using MySQL small operation before
MySQL is a c socket-based communication / s software architecture, so he also has server and client, the server startup program is mysqld bin folder, start the client program is mysql bin folder
The best will be added before running the MySQL bin directory to the system environment variables, so that we can open the program directly
First, we use the Administrator cmd to open the terminal
Server open: direct input mysqld
Open Client: cmd reopen a terminal window, enter mysql -h 127.0.0.1 -p 3306 -uroot -p, if the local IP and port number may be omitted
Exit the client: exit or quit
View all databases: show databases
View a process: After exiting the terminal database input tasklist | findstr + Name
Kill a process: taskkill / F / PID + process ID
Note: 1.MySQL when there is no initial login password, you can directly enter,
2.MySQL sql statement, is a semicolon, the semicolon does not knock no losers default, the client will continue to let us enter
Production environment variable
to the path where the startup files added to the system environment variables in
Note: Once you've configured a while to restart the mysql server and terminal cmd
Mysqld will be made into a system service
to make your system service must be the administrator cmd terminal
mysqld --install
Change password
without a password
mysqladmin -uroot -p password 123
the password case
mysqladmin -uroot -p123 password 123456
When the error command input can be used when \ c cancel the previous command cancel
Crack the code
first service has been launched end stopped
1. The user name and password to skip verification of the server function is activated
mysqld --skip-grant-tables skip start the server authorization table
2. modify the administrator password corresponding to the user
update mysql.user set password = password (123 ) where user = 'the root' and Host = 'localhost';
3. the server again to close the current username and password verification as to start
4. in the normal manner username and password server connected mysql
Profiles
\ s View mysql server simple configuration
suffix configuration files are usually ini end
mysql do not modify the configuration file that comes with
it you can create a configuration file my.ini
mysql server will automatically load the configuration in your configuration file in the startup my.ini
Need to first stop the server is restarted after changing the configuration file to take effect
Modify the configuration file must restart the server
Basic operation within 4.MySQL
1 . Operation folder (Library) by: create database db1 charset utf8; search: show databases; check all
show create database db1; check single change: alter database db1 charset latin1; modified encoding deleted: drop database db1; deletion library 2 . operation file (table) to switch to the next folder: use db1; specify the library
select database (); View current library of increase: create table t1 (id int, name char); check: show tables; see below in a library All tables
show create table t1; view information single table
desc t1; description See table changes: ALTER table T1 Modify name char ( . 3 ); ALTER table T1 change name NAME1 char ( 2 ); deleted: drop table T1; . 3 . contents file operation (recording) by: insert into t1 values (. 1, ' egon1 ' ), (2, ' egon2 ' ), (. 3, ' egon3 ' ); can be inserted into a plurality of check: SELECT * from T1; Search field information
select name from t1; Search fields specifying information
select name from t1 where id = 1 ; query information field with filter conditions change: Update T1 SET name = ' SB ' WHERE ID = 2 ; a modified data information field, which can be modified to delete: Delete from T1 WHERE ID = 1 ; delete the specified condition data
delete from t1; delete all the data in the table empty table: the delete from T1; # if there is increment id, the new data is still the same as before they were removed as the last start. truncate table t1; large amount of data, delete a speed faster than, and directly from scratch, * AUTO_INCREMENT represents: the self-energizing * primary key represents: constraint (repeats not and can not be empty); Find the acceleration