In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
After starting the service with the package, the relevant configuration files will be automatically generated.
The root initial secret is automatically generated the first time it is run
The initial password looks for grep-I password / var/log/mysql.log in the service log file
Get in there, mysql.
Mysql-hlocalhost-uroot-p initial password
Set global validate_password_policy=0
# change password default level is 0
# 0 is the length, 1 is the letter length symbol, 2 is the letter length symbol, dictionary file
Set global validate_password_length=6
# the default length of the modified password is 6
Alter user root@ "localhost" identified by '123456'
# change password
The command line instruction is temporarily valid, and the command is written to the configuration file / etc/my.cnf for permanent effect
Restart the service after the write is completed.
#
Noun interpretation
DB,DataBase
A collection of data organized according to a data model and stored in storage
DBMS,DataBase Management System
Database management system, large server software used to operate and manage databases
DBS, DataBase System
Server with database, database management system
#
Classification of sql commands
DDL data definition language
(create alter drop)
DML data manipulation language
(insert update delete)
DCL data control language
(grant revoke)
DTL data transaction language
(commit rollback savepoint)
#
2 create a library
Create database library name
# create a library
Show databases
# View existing libraries
Drop database library name
# deleting a library
Select database ()
# View the current library
Use library name
# enter the library
#
Build a table
Create table library name. Table name (
Field name type (width) constraint
Field name type (width) constraint
...
...
);
Create table gamedb.stu (
Name char (10), # characters (10)
Age int # numeric value
);
Insert into library name. Table name values (values list)
# insert table record
Select * from library name. Table name
# View table records
Delete from library name. Table name
# Delete table records
Desc library name. Table name
# View table structure
Drop table library name. Table name
# Delete table
#
Mysql data type
Numerical type: × ×, floating point type
Integer: according to the range of stored values, the type of integer is divided into:
Type tinyint smallintmediumintintbigint
The use is small, medium and large.
Size 1 byte 2 bytes 3 bytes 4 bytes 8 bytes
Divided into signed and unsigned, the ranges are as follows:
Signed-128-27-32768-2767-2 ^ 23 ~ 2 ^ 23-1-2 ^ 31 ~ 2 ^ 31-1-2 ^ 63 ~ 2 ^ 63-1
Unsigned 02550065535502 ^ 24-10-2 ^ 32-10-2 ^ 64-1
When you use unsigned modification when creating, only positive numbers are saved in the corresponding fields.
The width is only the display width, and the size of the stored value is determined by the type
When using zerofill, fill in 0 instead of blanks
# for example: age int (3)
The insert in to a values (3) database is displayed as 003
An error is reported when the value is out of range
Floating point type: according to the range of storage, it can be divided into single precision and double precision:
Single precision float (nQuery m) 4 bytes
Double precision double (nQuery m) 8 bytes
# n represents the total number of places and m represents the number of decimal places
# for example: float (5) the maximum is 999.99 and the minimum is-999.99
The width of the numeric type is that the display width cannot limit the size of the assignment to the field, which is determined by the field type.
#
Character type:
Fixed length: char (number of characters)
# the maximum length is 255 characters, which is filled with a space on the right if it is not enough to specify the number of characters. If the number of characters exceeds, the data cannot be written.
Variable length: varchar
# allocate storage space according to the actual size of the data. When the number of characters exceeds, the data cannot be written.
Large text type: text/blob
Used when the number of characters is greater than 65535.
Char is used more often in the actual production environment because varchar takes up part of the CPU resources to calculate the storage size.
Date and time type
Year YYYY 2017
# year defaults to 4 as a number. When only 2 digits are used to assign values, 01 to 69 is regarded as 2000 to 2069.
70: 99 is 1970: 1999.
Date date YYYYMMDD20171220
Time time HHMMSS155145
Date and time
Datetime YYYYMMDDHHMMSS
Timestamp YYYYMMDDHHMMSS
When datetime does not assign a value to him, it will be empty
When timestamp does not assign a value to him, it uses the current system time
#
Now ()
# time of the current system
Year ()
# get the year in the data
Day ()
# get the days in the data
Date ()
# get the date in the data
Time ()
# get the time in the data
#
Enumeration type: the value of a field can only be selected within the range of enumerations
Field name enum (values list)
# Select to select a single value from a given set of values.
Field name set (values list)
# multiple selections, select one or more values from a given set of values.
#
Set the constraints of the field: the function limit how to assign a value to the field.
Whether Null is allowed to be empty or not is followed by NOT Null after the type.
Default sets the default value, which defaults to NULL followed by default
#
Modify table structure
Mysql > alter table table name execute action
Add field name type (width) constraint
# add a new field. Default is at the end.
Add field name type (width) constraint first
# the front of all fields
Add field name type (width) constraint after field name
# what field should be added after
Drop field name
# deleting a field
Modify field type (width) constraint
# modify field type
Change original field name new field name type (width) constraint
# modify field name
Alter table original table name rename new table name
# modify the table name
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.