I. Introduction to database-related
Database Concepts
Database Concepts 1 . Random 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 in the local section 3. Save the data saved to a public place All user data related to the relevant public must be the place to find
MySQL 2. The database
The MySQL database is essentially a web-based application to communicate any underlying network-based communications software are socket server - socket-based communication - sending and receiving messages - SQL statement (a common standard) client - based socket communication - transceiver message - 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
3.DBMS: Database Management Systems
Classification database
DBMS: database management system
relational database
can be linked and limitations of 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 specific the type of
store name string
with digital access passwords
stored with date of birth
MySQL, oracle, sqlite, db2, sql server
non-relational databases
often store data in the form of k, v keys
very redis, mongodb (document database close relationship type non-relational data), memcache
4.MySQL internal structure
MySQL can actually see it as a support for remote file operations software 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 field name + field type
Two, MySQL database installation and basic use
1.MySQL download and install
https://www.cnblogs.com/Eva-J/articles/9669675.html
Note: In the IT industry, do not easily try the latest version of the software
After downloading, is the MySQL server and client download down
first extract
and then view the directory
server: mysqld
client: mysql
The basic use of 2.MySQL
Start mysqld 1 . Switch to the bin directory 2 execute mysqld. PS: do pre-configured MySQL when the terminal is recommended that you use an administrator running Windows + r to start an ordinary user mysql when the initial landing was not directly enter a password to mysql sql statement is a semicolon does not knock you completely do not enter a semicolon default client will let you continue to enter the client landing mysql -h 127.0.0.1 -P-uroot-3306 - 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; to see all the databases show databases; view a process tasklist | findstr name to kill the process taskkill / F / PID process ID
Third, configure the environment variables, making the system service
1. Create an environment variable
Production environment variable
path where the file will start to add to the system's environment variables
Note: Once you've configured a while to restart the mysql server and terminal cmd
2. mysqld made into a system service
Mysqld will be made into a system service
production system services your administrator cmd terminal must be a
mysqld --install
Fourth, change passwords, cracking passwords
1. Change Password
Without a password mysqladmin -uroot--p password 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
2. crack the code
Crack the code first service has been launched end stopped 1 Skip Authentication Enable server user name and password mysqld --skip-grant- the Tables start the server to skip the authorization table 2 . Modify the administrator password corresponding to the user update mysql SET password the .user = password (123) WHERE user = ' the root ' and Host = ' localhost ' ; . 3 . Close this manner the server to re-authenticate the username and password to start 4. in the normal manner username and password connection service mysql end
5, configuration files related operations
1. Profiles
Profiles
\ s see a simple configuration mysql server
configuration file suffixes 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 in your startup configuration within the configuration file my.ini
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
2. Create a new configuration file my.ini
[mysqld] Character -set-Server = UTF8 collation -server = utf8_general_ci [Client] default -CHARACTER-SET = UTF8 [MySQL] default -CHARACTER-SET = UTF8 # may also add an administrator account and password User = ' the root ' password = 123
3. Note
My_default.ini own profile can not be changed, only the new format for the ini file
Review reasons: in the mysql gbk encoding utf-8 format to
When starting mysql, this will automatically trigger my.ini configuration file
So we can be the administrator's name and password into the configuration file, mysql when you do not need to log in to write passwords, you can start the mysql
Six, MySQL basic operations
Operation 1. Library
Library: Folder similar increase create database db1; add a library search show databases; check all show create database db1; check single change ALTER Database DB1 charset = ' GBK ' ; modified encoding puncturing drop database db1; deletion library
2. The operation table
Table need to be specified when creating a table in the 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; see below a library All tables Show Create table UserInfo; desc UserInfo; <==> DESCRIBE UserInfo; modified ALTER Modify table UserInfo name char ( 32 ); puncturing drop table userinfo;
3. Record of operation
Record created to a database or specify an existing library switch to this database, create a 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 search the SELECT * from UserInfo; to query all field information the SELECT namefrom 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 ; a modified data field information update SET name UserInfo = ' 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