当前位置:网站首页>Operation of MySQL Library
Operation of MySQL Library
2022-07-24 14:45:00 【GSX_ MI】
Catalog
3. Character set and verification rules
1. Create database
grammar
CREATE DATABASE [IF NOT EXISTS] db_name [create_specification [, create_specification] ...]
create_specification:
[DEFAULT] CHARACTER SET charset_name
[DEFAULT] COLLATE collation_name- Uppercase means keywords
- [] Optional.
- CHARACTER SET: Specifies the character set used by the database
- COLLATE: Specifies the verification rules for the database character set
2. Create database case
- create database db1;
- When we create a database without specifying the character set and validation rules , The system uses the default character set :utf8, The verification rule is :utf8_general_ ci
(2) Create a use utf8 Of the character set db2 database
- create database db2 charset=utf8;
- create database db3 charset=utf8 collate utf8_general_ci;
3. Character set and verification rules
(1) View the system default character set and verification rules
show variables like 'character_set_database';
show variables like 'collation_database';
(2) View the character sets supported by the database
show charset;- The character set mainly controls what language to use . such as utf8 You can use Chinese

(3) View the character set verification rules supported by the database
show collation;- The so-called verification rule is that when we store data, we store it normally , What kind of verification method should we use when taking ( Coding format ) Compare our data

(4) The impact of validation rules on the database
① Case insensitive : Create a database , Verification rules use utf8_ general_ ci[ Case insensitive ]

② Case sensitive : Create a database , Verification rules use utf8_ bin[ Case sensitive ]

③ The query
- Case insensitive queries and results : test1

- Case sensitive queries and results : test2

④ Sorting results
- Case insensitive sorting and results :test1

- Case sensitive sorting and results :
4. Manipulating databases
(1) view the database
show databases;
(2) Show create statement
show create database Database name ;
explain :
- MySQL It is suggested that we use uppercase for keywords , But it's not necessary .
- Backquotes for database names ' ' , This is to prevent the database name used from being just a keyword
- /*!40100 default.... */ This is not a comment , At present mysql The version is greater than 4.01 edition , Just carry out this sentence
(3) modify the database
ALTER DATABASE db_name [alter_spacification [,alter_spacification]...]
alter_spacification:
[DEFAULT] CHARACTER SET charset_name
[DEFAULT] COLLATE collation_name- Modifying the database mainly refers to modifying the character set of the database , Validation rules
example : take test1 The database character set is changed to gbk

(4) Database deletion
DROP DATABASE [IF EXISTS] db_ name;- The corresponding database cannot be seen inside the database
- The corresponding database folder is deleted , cascading deletion , All the data tables inside have been deleted
- Be careful : Do not delete the database at will
5. Backup and recovery
(1) Backup
# mysqldump -P3306 -u root -p password -B Database name > File path of database backup storage ① Example : take test2 Back up the library to a file ( Exit connection )

② see test.sql The contents of the document , In fact, we create the entire database , Build table , The statements that import data are loaded with this document In the piece .

- The so-called backup , The essence is to put history on mysql All historical operations of the specified database , Make a backup .
- mysql How can I know that I have entered those in history sql Commands and data ? mysql You should know ,binlog, Almost all operations on the specified database are recorded !
(2) Restore
mysql> source Backup data path 

(3) matters needing attention
- # mysqldump -u root -p Database name Table name 1 Table name 2 > D:/mytest.sql
② Backing up multiple databases at the same time
- # mysqldump -u root -p -B Database name 1 Database name 2 ... > Database storage path
6. Check the connection
- Can tell us which users are currently connected to our MySQL, If you find out that a user is not logged in normally , It is likely that your database is Someone invaded . Later, when you find that your database is slow , You can use this command to check the database connection
show processlist- id #ID identification , want kill A sentence is very useful
- use # Currently connected users
- host # Show which... This connection comes from ip On which port of
- db # Database name
- command # Connection status , Usually dormant (sleep), Inquire about (query), Connect (connect)
- time # Connection duration , The unit is seconds
- state # Show the current sql The state of the statement
- info # Show this sql sentence
边栏推荐
- [matlab] matlab drawing Series II 1. Cell and array conversion 2. Attribute cell 3. delete Nan value 4. Merge multiple figs into the same Fig 5. Merge multiple figs into the same axes
- Activate the newly installed Anaconda in the server
- mysql
- 记不住正则表达式?这里我整理了99个常用正则
- spark:获取日志中每个时间段的访问量(入门级-简单实现)
- After reading this article, I found that my test cases were written in garbage
- Notes on the use of IEEE transaction journal template
- Native asynchronous network communication executes faster than synchronous instructions
- Production environment tidb cluster capacity reduction tikv operation steps
- Learning and thinking about the relevant knowledge in the direction of building network security knowledge base
猜你喜欢

Isprs2018/ cloud detection: cloud/shadow detection based on spectral indexes for multi/hyp multi / hyperspectral optical remote sensing imager cloud / shadow detection

Spark: get the access volume of each time period in the log (entry level - simple implementation)
![[NLP] next stop, embossed AI](/img/fc/4997309d0d53c5b6eb441ac39e6929.jpg)
[NLP] next stop, embossed AI

深入浅出边缘云 | 2. 架构

Must use destructuring props assignmenteslint

Spark Learning Notes (III) -- basic knowledge of spark core

不要灰心,大名鼎鼎的YOLO、PageRank影响力爆棚的研究,曾被CS顶会拒稿

Detailed explanation of IO model (easy to understand)

多数据源配置下,解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题

北京一卡通以35288.8529万元挂牌出让68.45%股权,溢价率为84%
随机推荐
多数据源配置下,解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题
Caffe framework and production data source for deep learning
Rasa 3.x 学习系列-Rasa [3.2.4] - 2022-07-21 新版本发布
Tensorflow framework of deep learning realizes vgg/rnn network / verification code generation and recognition / text classification
Problem handling of repeated restart during Siemens botu installation
Under multi data source configuration, solve org.apache.ibatis.binding Bindingexception: invalid bound statement (not found) problem
spark:获取日志中每个时间段的访问量(入门级-简单实现)
IEEE Transaction期刊模板使用注意事项
Error when using Fiddler hook: 502 Fiddler - connection failed
Not configured in app.json (uni releases wechat applet)
Attributeerror: module 'distutils' has no attribute' version error resolution
Centos7安装达梦单机数据库
Can't remember regular expressions? Here I have sorted out 99 common rules
Date processing bean
Beijing all in one card listed and sold 68.45% of its equity at 352.888529 million yuan, with a premium rate of 84%
threw exception [Circular view path [index]: would dispatch back to the current handler URL [/index]
The first n rows sorted after dataframe grouping nlargest argmax idmax tail!!!!
Clear all spaces in the string
解决 uni-starter 使用本地函数可以登录微信 但是使用云函数登录失败
JS judge whether the data is empty
