Acquaintance MySQL database

And in the knowledge database

 1: What is the data (Data)

   Symbol records describe things is called data, this symbol can be numbers, text, pictures, sound, language, etc.

2: What is the database (DataBase, referred to as DB)

  The database is stored in the data warehouse, the library is normally stored on a computer storage device, and the data is stored in a certain format

3: What is a database management system (DataBase Mangement System abbreviation: DBMS)

  Relational data: there can be between data associated with the data and limitations; databases are usually relational table structure, that is, means that you are using relational data when

  Non-relational database: based on key-value store, there is no table structure

Relational: such as: sqllite, db2, oracle, access, sq1 sever, MySQL, note: sql statement General

Non-relational: mongodb (document type data, very close to non-relational data relational), redis, memcache

 

Second, the acquaintance MySQL

  1, MySQL is a relational database management system, developed by the Swedish company MySQL AB, Oracle's currently owned company

What mysql that?

  Is based on a socket (socket) prepared by the c / s architecture of the software, is essentially a web-based application to communicate 

    Server
        - based socket communication
        - messaging
        -SQL statement (a common standard)
    client
        - based socket communication
        - messaging
        -SQL Statement

ps: MySQL only supports MySQL client to operate, but also support other programming languages ​​directly manipulate

  python, java, c ++, php, c, etc., just not the same syntax

2, related concepts:

 MySQL can actually see it as a software support remote file operations

Library: that folder

Table: is the file

Record: data in the file line by line in a section called the record

 

Header: is the first row of the table

Fields: Field Name Field Type +

Third, the installation and use of MySQL

  In the IT industry, Do not try to install the latest version of the software. Unstable, not necessary Bug prone, and difficult to repair

1, substantially the steps of:

  Download the official website (5.7 / 5.6 version) >> Download >> Open unzip find mysl.exe bin directory, copy the path environment variable to add >>> >>>

Open CMD >>> mysqld with administrator privileges to open the server >> mysql -uroot -p open a connection to the server to server >> made into a system service (boot) 

2, start command : D: (switching to the D drive) >>> cd + exe file folder path where the input mysql.exe or mysqld.exe >>

3, Common operation command:

  (1) mysql sql statement is a semicolon; for the end, do not lose a semicolon, by default you do not have losers, will continue waiting for input,

  (2) When the command input can be used when error \ c cancels the previous command cancel

  (3) \ s View mysql server simple configuration

 

4, client logon : mysql -h 127.0.0.1 -P 3306 -uroot -p can be abbreviated: mysql -uroot -p

  If you do not enter a user name and password by default is landed guest mode function can be used rarely

5, the client logout : exit; quit;

6, to see all the databases: show databases;

7, view a process : tasklist | findstr name (mysql or mysqld)

8, kill the process:  taskkill / F / PID process ID (dynamic)

9, the production environment variable
      to start the path to the file where the environment variable added to the system's
    Note: After configuring a while to restart the mysql server and terminal cmd
10, will be made into a system service mysqld
      production system services you must be the Administrator cmd terminal
    mysqld --install
11, change passwords
      without a password
          mysqladmin -uroot -p password 123
      the password case
          mysqladmin -uroot -p123 (original password) password 123456
12, crack the code
 
   First service has been launched off the end stop
 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
 

13: Profile

  
  \ 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
# Above mysql5.5: modifications subject to change 
[mysqld] 
Character -set-Server = UTF8 
collation -server = utf8_general_ci 
[Client] 
default -CHARACTER-SET = UTF8 
[MySQL] 
default -CHARACTER-SET = UTF8 

# 2. Restart service 
# 3 View modify the result: 
\ S

  Can also be in the configuration file, the customer service end user and password in mysql bind directly to run as an administrator to view

Fourth, the basic operation of the database:

  Library: similar to folders

        By 
            create database db1; 

        investigation 
            show databases; check all 
            show create database db1; check single 

        change 
            ALTER Database charset = DB1 'GBK' ; modified encoding 

        puncturing 
            drop database db1; deletion library        

 Table: Similar documents

You need to be specified when creating a table of library 
            specify the library: use library name 
            to view the current, although in the library: select database () 


        by 
            create table userinfo (id int, name char); 

        check 
            show tables; all of the following to view a library table 
            Show Create table UserInfo; 
            desc UserInfo;     <==> DESCRIBE UserInfo; 
        modified 
            ALTER Modify table UserInfo name char ( 32 ); 
        puncturing 
            drop table userinfo;

 

Record: data in the file line by line in a section called the record

Create to a library or specify an existing library 
        switch to this library to create the table 
        and then the operation record 
Create Database DB1; Create Table UserInfo (ID int, name char (
32 ), password int); growth INSERT INTO UserInfo values ( . 1 , ' Jason ' , 123 ); inserting a single data iNSERT INTO UserInfo values ( . 1, ' Jason ' , 123), (2, ' Egon ' , 123), (. 3, ' Tank ' , 123 ); inserting a plurality of data search the SELECT * from UserInfo; to query all field information name SELECT from UserInfo; field information query specifies SELECT ID, name from UserInfo ID = WHERE. 1 or name = Tank; information field with filter conditions change Update UserInfo SET name = ' Kevin ' WHERE ID =. 1 ; modify a data field information Update UserInfo SET name = ' Jason ' , password = WHERE ID = 666. 1 ; a plurality of data fields modify delete delete from UserInfo ID = WHERE. 1 ; designated qualified data deletion delete from UserInfo; delete all the data in the table

 

 

 

 

 

 
 
  
 
 

 


      

 

 

  

 

 

 

 

 

 

 

 

  

 

Guess you like

Origin www.cnblogs.com/Gaimo/p/11366371.html