How to download:
I'll go to MySQL. Home Download the latest version of mysql-Link: https://www.mysql.com/downloads/
Enter this interface to download:
Downloads–>mysql Community Edition (GPL) (this is the free version, of course, the money can be used for a fee, more powerful) –>mysql Community Server (GPL)
–> Select the corresponding system and computer version (here, I chose the Window System 64-bit download)
–>no Thanks, just start my download.
How to install:
Because it is free to install, we download a good compression package, directly extracted to the directory we want to install it.
To create a new My.ini file, paste the following code (note: Basedir and DataDir are modified to their own installation path):
[mysql]# 设置mysql客户端默认字符default-character-set=utf8#设置3306端port = 3306# 设置mysql的安装目basedir=D:\\mysql-5.7.14-winx64# 设置mysql数据库的数据的存放目datadir=D:\\mysql-5.7.14-winx64\\data# 允许最大连接max_connections=200# 服务端使用的字符集默认为8比特编码的latin1字符character-set-server=utf8# 创建新表时将使用的默认存储引default-storage-engine=INNODB
Open the CMD Command window (run with Administrator privileges), go to the installation directory bin directory and execute the command:
Mysqld–initialize-insecure–user=mysql Enter, the data folder is automatically created in the MySQL installation directory.
command line to install MySQL:
Registration Service (note as administrator: Open "C:\Windows\System32" in My Computer, find the file "Cmd.exe", right click, select "Run as Administrator (A), go to the directory" D:\mysql-5.7.14-winx64 ", Then run the following code)
Bin\mysqld–install Mysql-5.7.14-winx64–defaults-file=d:\mysql-5.7.14-winx64\my.ini
Start the service (Run as Administrator)
net start mysql-5.7.14-winx64
– You can also right-click on "My Computer" | Manage "|" Services and Applications "|" Service "| find" Mysql-5.7.14-winx64 ", right click, select Start
Command line login (the bin directory is set to the PATH environment variable, you can omit "bin\", the same as later)
Bin\mysql-u root-p
– If the password is empty, press ENTER directly
Set the password for root (when the original password is empty): mysqladmin-u root password "1234"
Change root password: mysqladmin-u root password OldPassword "Newpass"
Stop service (run as Administrator)
net stop mysql-5.7.14-winx64
– The service must be stopped before it can be deleted!
Delete Service (run as Administrator)
Bin\mysqld–remove mysql-5.7.14-winx64
Getting started with MySQL statements: dcl– Data Control Language
This is usually done by a DBA (a dedicated Database manager), and we're programmers, and we know what's on the line.
Create user Hncu identified by ' 1234 '; Create a user hncu password: 1234
Grant all on . to ' hncu ' @ '% ' with GRANT option; Grant all resources to the user Hncu, and allow him to log on on any machine using
Grant all on . to ' hncu ' @ ' 192.168.1.165 ' with GRANT option; Restrict the user from logging on to this machine with IP: 192.168.1.1685
Sign in with this hncu:
That's all that's going to be said.
ddl– Data Definition Language Language
Build libraries, build tables, set constraints, and more:
Create\drop\alter
There is a need to pay attention to the place: is the difference between Char and Vaechar;
Knowledge points for data types: char and varchar can be used to define the field of the character type, the difference:
CHAR (15)-Fixed length 15, if assigned only one character ' a ', then the inside data is: 1 characters ' a ' plus 14 spaces. -Compare character arrays similar to those in Java.
varchar (15)-Variable-length char array, if assigned only one character ' a ', then there is only one character ' a ' in the data. -Compare strings similar to Java
In some cases, we have determined that the value of a parameter must be so long that it can be used in char.
Create database Hncu character set UTF8;
Create a database Hncu, and set the encoding to Utf-8. The benefit of setting the encoding is not to rely on the default encoding inside the configuration file.
If you write this:
Create DATABASE [if not EXISTS] Hncu character set UTF8;
[If not exists]– determines whether HNCU exists and does not exist before it is created.
The database we just created:
Use Hncu;
Enter the HNCU database.
CREATE TABLE Stud (
Sno varchar () NOT NULL primary key,
sname varchar () NOT NULL,
Age int
);
Create a table stud that contains 3 columns: Sno,sname,age.
Not null-represents non-null.
Primary key-set the primary key, that is, Sno name must be unique!
DESC Stud;
Displays the structure of the stud table.
(This belongs to the DDL)
INSERT into stud values (' n ', ' Jack ', 20);
INSERT into stud values (' 1002 ', ' Tom ', 24);
INSERT into stud values (' 1003 ', ' Rose ');//This sentence is wrong, not less! (There are methods that specify which columns to insert later)
INSERT into stud values (' 1003 ', ' Rose ', 30);
Add a row and assign a value to the stud table
Sno can be "", but there will only be one!
ALTER TABLE STUD ADD column Tel int;
Add a column for the stud table for tel, type int.
(values are null because there are no assignments)
ALTER TABLE stud DROP COLUMN Tel;
Delete the Tel column under the Stud table
drop table stud;
Delete Table Stud,
Drop database Hncu;
Delete Database Hncu,
dml-Data Manipulation Language manipulation Language
Mainly refers to the deletion of data to check and change
Select\delete\update\insert\call
show databases; Show all data names
Use Hncu; Open the database "Hncu"
Show tables; Displays all table names for the current database
SELECT * FROM stud;
Show all records in the stud table
SELECT * FROM stud where sname= ' Tom ';
Show (query) all records of Sname= ' Tom '
Select Sname,age from Stud;
Display the specified field (column) in the Stud table
INSERT into stud values (' 1004 ', ' Zhang San ', 30);
Insert a record into the stud table
Delete from stud where sname= ' Tom ';
Delete the specified line-this is the row for Tom Sname.
Update stud set sname= ' John Doe ' where sno= ' 1003 ';
Modify the sname of the line Sno as ' 1003 ' to ' John Doe '
INSERT INTO stud (sno,sname) VALUES (' 1005 ', ' ronse ');
Inserts only the specified columns. (set to NOT NULL must be set, can be set to ")
Basically learn these simple sentences, slowly come, you have started!
Come on (^ω^).
mysql5.7.14-Download Installation Tutorial-->mysql Database statement Detailed tutorial