Today's content:
Introduction of 1.mysql
2. How to install mysql
3.mysql basic use
I. Introduction to Database
What is mysql:
mysql is an open source relational database management system (RDBMS),
due mysql is open source, so anyone can General Public License
download under license and modify it according to individual needs, because mysql its speed, reliability and
adaptability have attracted much attention, most people think without the need for transactional processing, mysql is
managing content best choice.
So why use the database:
Because using a file (Excel) data management before, but particularly large amount of data when using Excel management, then, is more a trouble
so the introduction of a new data management software: database software
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 locally 3. Save the part of the stored data to a public place all users of the data must be related to the common place to find
mysql database's schema:
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
Database Category:
Relational Database:
1 . Constrained 2. The disk-based storage (that is to store data to the hard disk, persistent === floor) typical: the MySQL, Oracle, SQLite, DB2, SQL Server there may be between the data associated with the limitations and relational databases are 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 the name of the string stored password using the deposit with the birthday date
Non-relational databases:
1. There is no constraint (Key ---> value) 2 memory-based storage (data will be placed into memory). Typical representatives: redis, mongodb (document database is very close to non-relational data relational), memcache
In fact, we can put a mysql as 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
II. How to install mysql
How to install mysql:
Mysql official website in Baidu search above, then download a suitable version, download the Community Edition.
Installing MySQL in the IT industry do not easily try the latest version of the software after downloading is the MySQL server and client download down decompression view the file directory server mysqld client mysql to start mysqld 1 . Switch to the bin directory under 2 Executive mysqld PS: do pre-configured MySQL when the terminal is recommended that you run as administrator Windows + r to start an ordinary user mysql landing at the time of the initial password is not directly enter the end mysql sql statement is a semicolon do not knock you completely did not enter a semicolon default client will let you continue typing
Installed on how to log in:
The client landed 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; View all databases show databases; view a process tasklist | findstr name to kill the process taskkill / F PID process ID /
That every time you start mysql must manually add environment variables:
So how to make the environment variables:
How the server only as a system service:
Production environment variable
to the path where the startup files added to the system's environment variable
Note: Once you've configured 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
How to change your 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
If your password is forgotten how to do:
Crack the code will now have to start the server 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
How to configure your own files in mysql, execute your order at the time of start mysql:
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
Basic use three .mysql database:
The basic operation of the database: a total of three categories, databases, data tables, data lines,
All CRUD
One: the basic operation of the database:
By: cerate Database database name; search: Show Databases; get all the database show create database database name; check specified database changes: ALTER database name Database charset = ' GBK ' ; modified encoding deletion: drop Database name database; deletion library
II: The basic operation of the data table:
Note: When you create a table, you need to specify what you want to create a table in the library.
Specify the library: use library name
View library is currently located: select database ()
By: the Create the Table data table name (id int, name char); check: Show the Tables; view a library of all the tables below show create table table name: View the process of creating a table desc table name; see table structure change : ALTER table data table name char Modify ( 32 ); deleted: drop data table name; drop table
III: the basic operation of the data line
Note: to create a database or specify an existing library
The library is then switched to the next, to create the table, and then add the data in the operation data line
By: insert into the data table values ( . 1, ' Jason ' , 123 ); inserting a single data insert into the data table values ( . 1, ' Egon ' , 123 ) (...); inserting a plurality of check: SELECT * from data name; all the field information table queries select field from the data table; query information specified field select field, the field from the data table. 1 = ID WHERE or name = Egon; query information field with filter conditions change: update the data table name SET = ' ZY ' WHERE ID =. 1 ; a modified data field information update data table name SET =' Jason ' , password = 666. 1 = ID WHERE ; a plurality of data fields to modify deletion: Delete from the data table. 1 = ID WHERE ; delete data that match specified criteria Delete from the data table; all delete all the data in the table