Database & MySQL

Database infrastructure
  Chapter 1: Introduction Database
Database
    database (dataBase, DB) is a collection of long-term storage in the computer, organized, sharable data.
 Data in the database according to a certain mathematical model of organization, description and storage, has less redundancy, higher data independence and ease of scalability, and can be shared by various users.
Database management system software
    DBMS (Database Management System) is a large-scale software for manipulating and managing a database, used to create, use and maintenance of the database, referred to as DBMS.
 It unified database management and control, in order to ensure the security and integrity of the database.
 Users, database administrators perform database maintenance by dbms DBMS data by accessing the database.
 It allows multiple applications and users in different ways to different times or at the same time to establish, modify and query a database.
 Most DBMS provides data definition language DDL (Data Definition Language) and data manipulation language DML (Data Manipulation Language), the structure and mode permissions for user-defined database constraints, to achieve the additional data, delete files.
    Database management system is the core database system is a database management software.
 Database management system is to achieve the abstract sense the user data processing logic, computer software specifically converted into a physical data processing.
 With database management system, users can process data in an abstract sense, without regard to the layout and the physical location of the data on your computer.
    Common database management software: Oracle oracle, IBM's db2, sql server, Access, MySQL ( open source, free, cross-platform)
database system
    Database system DBS (Data Base System, referred to as DBS) typically consists of software, databases and data administrators.
     The software includes an operating system, various host languages, utilities, and database management systems.
     Unified database managed by the database management system, data insertion, modification, and retrieval have to be carried out by database management systems.
     Data administrator is responsible for creating, monitoring and maintenance of the entire database, the data can be used by any person is entitled to effective use.
The MySQL
  the MySQL Management
- installation
 --linux:
yum the install MariaDB MariaDB -Y-Server
OR
yum the install MySQL MySQL -Y-Server
 - Windows:
http://dev.mysql.com/downloads/mysql/
- Start
service mysqld start - open
chkconfig mysqld on - set the boot from Kai
OR
systemctl Start MariaDB
systemctl enable MariaDB
- View
ps aux | grep mysqld - view the process
netstat -an | grep 3306 - see the port
- set a password
mysqladmin -uroot password '123' - to set the initial default password is not empty and therefore with the -p option
-u root -p123 password mysqladmin '1234' - Changing the root password
- log
MySQL - local login, user default root, empty password, user [email protected]
mysql -u root -p 1234 - local login, specify the user name and password, the user is [email protected]
MySQL -u root -p 1234 -h 192.168.31.95 - remote login, the user is [email protected]
--MYSQL common commands
- Start and stop the mysql service mysql service command:
   NET Start mysql
   NET STOP mysql
- landing and exit the command:
   MySQL server IP -P port number -h -u user name -p password
 - MySQL -h 127.0.0.1 -P 3306 -u root -p 123
- profile
/ * my.ini file : [MySQL] default-Character-the SET = GBK
               [mysqld] Character-the SET-server = GBK * /
     
? (? \) to display help information
clear (\ c) clear the current input statement
connect (\ r) is connected to the server, selected from the parameters database and host
delimiter (\ d) setting statement separator
ego (\ G) sends a command to the MySQL server, and display the results
exit (\ q) exit MySQL equivalent to quit
Go (\ G) sends a command to the MySQL server
help (\ h) to display help information
notee (\ t) does not write the output file
print (\ p) Print command
prompt (\ R) to change the MySQL prompt
quit (\ q) quit MySQL
rehash (\ #) to complete the re-hash
source (\.) execute a SQL script file to a file name as an argument.
status (\ s) to obtain MySQL server status
tee (\ T) is provided to add the output file, and the information is given to the output file of all
use (\ u) with another database, the database name as a parameter
charset (\ C) switch to another character set
to display a warning after warnings (\ W) each statement
without warning after nowarning (\ w) for each statement
SQL specification and
SQL (Structured Query Language Structured Query Language) is a database query language and programming language, used primarily for data management database, such as data access, query data, updating data and the like.
SQL is a database operation command set designed for established and is fully functional database language.
 When using it, just issued a "what" command, "how" the user is not taken into account.
 SQL is powerful, easy to learn, easy to use, has become a basic database operations, and now almost all of the database support SQL.
<1> in a database system, SQL statements, case-insensitive. However, case-sensitive string constants. The proposed order uppercase, lowercase table names library name;
<2> SQL statements can be single or multiple rows written with ";" at the end. Keywords can not span multiple lines or abbreviated.
<3> with spaces and indentation to improve readability of the statement. Clause typically located on a separate line, to facilitate editing, improve readability.
 * The FROM tb_table the SELECT
             the WHERE NAME = "YUAN";
<. 4> Note: single-line comments: -
          Multi-line comments: /*......*/
<. 5> the SQL statements can be folded operative
<6> SQL language by the DDL, DML, DQL and DCL composition
   (1) database definition language (Data Definition language,

                 CREATE statement to create a database, data sheets, ALTER statement to change the definition of a table, etc., DROP statement to delete the database, delete the table and so on.
   (2) database manipulation language (Data Mabipulation Language, DML)
      database manipulation language mainly used for the database to add, modify, delete operations, including the INSERT statement, UPDATE, and DELETE statements languages.
                 INSERT statement is used to insert data, UPDATE statement to modify data, DELETE statement to delete data.
   (3) database query language (Data Query Language, DQL)
      database query language is mainly used to query language, refers to the SELECT statement.
                 One or more data SELECT statement to query the database.
   (4) Database Control Language (Data Control Language, DCL)
      database control language mainly used to control user access rights, including the GRANT statement, REVOKE statement, COMMIT statement and the ROLLBACK statement.
                 GRANT statement is used to increase user permissions, REVOKE statement is used to recover the user's permission, COMMIT statement to commit the transaction, ROLLBACK statement is used to roll back the transaction.

Guess you like

Origin www.cnblogs.com/lixiangyi200174/p/11729983.html