Getting day34 database


Database Concepts

# 1 casual saved to a file in the data format is vastly different 
# 2. Software development directory specification 
  defines the location data stored 
  ps: data are stored locally 
# 3. Save the part of the stored data to a common where all the relevant data related to the user must be the place to find public

 

 

The MySQL database

 

# Is essentially a web-based application to communicate 
# any underlying network-based communications software are socket 

server
 - based socket communication
 - sending and receiving messages
 - SQL statement (a common standard) 
client
 - based socket communication
 - send and receive messages
 - SQL statement 

ps: MySQL not only supports MySQL client to operate also support other programming languages directly manipulate 
Python the Java c ++ PHP syntax is different

 

 

DBMS: Database Management System

Relational Database

# Can have associated limitations and data between the data and the 
relational database usually table structure, which means you're in a relational database 
first step is to determine the structure of table 

fields have a specific type of 
memory with a string name 
save the password with the number 
stored with date of birth 

MySQL, oracle, sqlite, db2, sql server

 

Non-relational databases

# Usually are stored as data k, v keys 
redis, mongodb (document database is very close to non-relational data relational), memcache

 

 

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

>>> library folder 
list >>> file 
records >>> data in the file line by line, called a section of the recording 


header is the first line of the data table 
field the field name + Field Type

 


Installing MySQL

# In the IT industry, do not easily try the latest version of the software 

after the download is the MySQL server and client download down 
decompression: Click to open directory 
server: mysqld 
client: mysql

 

Start mysqld

1 Switch to the bin directory of
 2 execution mysqld. 
PS: do pre-configured MySQL when the terminal is recommended that you run as administrator 

Windows + r to start an ordinary user 

mysql when the initial landing was not directly enter a password 

mysql sql statement is a semicolon does not knock you completely do not enter a semicolon default 
client will let you continue typing

 

 

Client Log

-h 127.0.0.1 -P 3306-uroot-MySQL - the p- 
can be abbreviated 
MySQL -uroot-- the p- 

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

clients logout 
Exit; 
quit;

 

View

# View all the database 
Show Databases;
 # view a process 
tasklist | findstr Name
 # kill process 
taskkill / F / PID process ID

 

 

Production environment variable

The startup files are located in the path environment variable added to the system's 
Note: After configuring a while to restart the mysql server and cmd terminal 

will be made into a system service mysqld 
production system services your administrator cmd terminal must be a 

mysqld --install

 

 

change Password

# Without a password 
mysqladmin -p password-uroot-123 # under have a password 
mysqladmin -uroot -p123 password 123456 
when the command input error can be used when \ c cancel the previous command cancel

 

decryption

Has now launched the server stopped 

# 1 to skip authentication username and password function is activated server 
    mysqld --skip-grant- the Tables start the server to skip the authorization form
 # 2. Modify the administrator password corresponding to the user 
    update mysql SET password = password the .user (123) WHERE user = ' the root '  and Host = ' localhost ' ;
 # 3. Close the current verification server again to the way a user name and password to start 
# 4 in the normal way connection username and password mysql server

 

 

Profiles

\ s View mysql server simple configuration 
suffix configuration files usually are ini the end of the 

mysql configuration file that comes not to modify 
, but you can create a configuration file my.ini 
mysql server will automatically load your my start. ini configuration in the configuration file 

need to first stop the server restart to take effect after you finish modifying the configuration file 

to modify the configuration file must restart the server

 


The basic operation of the database
library similar to folders

# Increasing 
    Create Database DB1;
 # investigation 
    show databases; check all 
    show create database db1; single check 
# change 
    ALTER Database charset = DB1 ' GBK ' ; modify codes
 # puncturing 
    drop database db1; deletion library

 


table

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: the SELECT Database () 

# increasing 
    the Create UserInfo (the above mentioned id int, name char) the Table;
 # check 
    show tables; see below a library All tables 
    Show Create table UserInfo; 
    desc UserInfo; <==> DESCRIBE UserInfo;
 # change 
    ALTER Modify table UserInfo name char (32 );
 # puncturing 
    drop table userinfo;

 


recording

Create 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); 

# increasing 
    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
 # check 
    the SELECT * from UserInfo; to query all the fields of information 
    the SELECT name from  UserInfo; query information specified field
    the SELECT the above mentioned id, name from. 1 WHERE ID = UserInfo or name = Tank; information field with filter conditions
 # change 
    Update UserInfo SET name = ' Kevin ' WHERE ID =. 1 ; a modified data field information 
    Update UserInfo SET name = ' Jason ' , password = 666 ID. 1 = WHERE ; a plurality of modified data fields
 # delete 
    delete from UserInfo ID =. 1 WHERE ; qualified data specified delete 
    delete from UserInfo; delete all the data in the table

 

Guess you like

Origin www.cnblogs.com/Ryan-Yuan/p/11364562.html