First, the basic database, MySQL installation, configuration files, syntax

Today Summary: 

First, the database infrastructure *****
two: mysql download and install *****
Three: Change Password
four profiles ***
Five: Database basic grammar ******

First, the database infrastructure:
1 , database basic concepts

1, before saving to a file, the data format is vastly different
2, software development directory specification defines the storage location of the data, the data is stored locally,
3, will save the data, stored in a public where
MySQL is a software application based on C / S architecture, also a software application based on socket socket network communication
server: socket socket communication
messaging
SQL statement (a common standard)
server: socket sets Sockets communication
send and receive data
SQL statements that
MySQL does not support the operation itself only clients, but also support other programming languages directly manipulate
python Java c ++ php syntax is not the same
DBMS: database management system
1, a relational database (stored in the hard disk)
are associated and constraints between the data and the data
are generally table structure, you are using a relational database, the first a table structure determination step is
used with a relational database, the MySQL, Oracle, SQLite, DB2, SQL Server
2, non-relational database
is internal to k, v stored in the form of key-value data, based on (stored in memory)
Redis , mongodb (document database is very close to non-relational data relational), memcache
PS: MySQL can be seen as a remote file operations of a software
library === "folder
list ===" file
records === "line by line in the data file is a data line by line
header fields of
a" data type field of the field name field +
2 "header is the first row of the table

two: download mysql installation
1, go to the official website to download mysql (do not download the latest version)
2, unzip the file (the file name is not on the Chinese folder)
3, open the file switch to the bin directory folder, copy this folder path, in the system settings, open the advanced settings
in this open environment variable inside, so that double-clicking in the system environment path, and then click New River copy of the bin folder
path in which to add, then click OK to add the complete system environment variables
ps: the production environment variable
to start the path where the file is added to the system's environment variable
Note: Once you've configured a while to restart the mysql server and cmd terminal
4, in cmd the open division administrator, service-ended input mysqld, client MySQL
* * start mysqld (the server)
1. switch to the bin directory
2. Run the mysqld
Windows + r to start an ordinary user
ps: do pre-configured MySQL when the terminal is recommended that you use the Run as administrator
mysql when the initial landing was not directly enter the password
mysql sql statement is a semicolon does not knock you did not enter a default semicolon end
clients will allow you to continue to enter
*** mysqld will be made into a system service
production system services your administrator cmd terminal must be a
mysqld --install
other words, when you open the computer, the database server has been started (the server is set to Auto)

* * start the client: MySQL
client Login: mysql -h 127.0.0.1 -P 3306 -uroot -p
can be abbreviated:
MySQL-uroot--p
PS: If you do not enter a user name and password are tourists access, limited operation data
Exit the client landing;
Exit, or quit
PS: 1, viewing a process:
tasklist | findstr Name Case: tasklist | findstr MySQL
2, to kill a process:
taskkill / F / PID process number
three: Change Password:
not logged in mysql case, you know the password, modify
1, did not have the password to change the password (as an administrator cmd to open the terminal)
mysqladmin -p password-uroot-123 at this time will become the password changes 123
2, then password under the circumstances, modify the password
mysqladmin -uroot -p123 password 123456 password at this time will be changed to 123456
PS: order entry errors, ending it with \ c
crack the code:
first, turn off the server has been launched
1. Skip Authentication Enable server user name and password (as an administrator cmd to open the terminal)
MySQL --skip-Grant #-the Tables mean, start the server, skip the grant tables
2, modify the administrator user corresponding to the password, the client (the other input terminal cmd)
Update the mysql.user SET password = password (123) WHERE User = 'the root' and Host = 'localhost';
. 3, the server re-close the current at this time to verify username password way to start
4. normal manner username password connection mysql server
four profiles:
\ S View mysql server simple configuration
suffix configuration files usually are ini the end of the

mysql built-in configuration file do not modify
but you can create a configuration file my.ini
PS: Care must be taken not free himself from the file name and modify the contents of its original configuration file, the new file name is the my.ini, not the other
mysql server will automatically load the configuration in your configuration file in the startup my.ini

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

****** modified the configuration file must restart the server

five : database basic grammar:
1, library == "folder:
by: create database database name;
case column: create database db1; (be careful not less; number); the role of the end of the SQL statement is
deleted: drop database database name; ( Do not use easily in the actual work of the command) to delete the library on foot
case: drop database db1;
change :( generally have little change, direct re-build)
the ALTER database db1 charset = 'GBK'; modify the character encoding
check:
Show Databases; check all databases:
show create database db1; check a single database
2, Table == "file:
first select the library: that operate on that file in that folder
to select the library folder or switch syntax:
use database name; Case column: use db1;
See in the database: SELECT database ();
. 1, by: is the column operating
create table table name (field name field type field name field type)
create table User (ID int, name char (32), Age int )
here you pay attention to use the fields and field types, field to select the appropriate field type
1 "when the tables will succeed in this table if you also want to increase the field, the syntax is:
the ALTER the table the User the Add (the Anger char (32)) ;
2, the drop table
drop table table name;
drop table user;
. 3, modify table
alter table user modify name char (64 );
In this case the type of user data in the table name in this row becomes all the char (64)
. 4, Charles table
show tables; view a library of all the tables below
show create table user; see the process of creating user tables
desc user; see table structure
3 record === "line by line data:
certainly in terms of operations on the table:
to to the library, the operating table
Create Database DB1;
Create Table User (ID int, name char, Age int);
. 1, to increase the recording
insert into user values (1, ' jack', 18); inserting a single data
insert into user values (2, ' jerry', 23), (3, 'egon ', 25), (4, 'ete', 30); inserting a plurality of data
2, delete records
delete from user where id = 1; designated delete a matching records
delete from user ; delete all the data in the table,
3, change
update user set name = 'kevin' where id = 2; a modified data field information
update user set name = 'jason' , age = 666 where id = 1; a plurality of modified data fields
4, check
select * from user; all data in the table in
select name from user; see the contents of the column name specified query field information
select id name from user where id = 1 or name = 'jerry'; information field with filter conditions
select id name from user where id = 1 and name = 'jerry';

Guess you like

Origin www.cnblogs.com/Fzhiyuan/p/11369978.html