Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | 51CTO学院 | CSDN程序员研修院 | OSChina 博客 | 腾讯云社区 | 阿里云栖社区 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏多维度架构

部分 III. MySQL

目录

19. MySQL Server
19.1. MySQL 安装
19.1.1. Rocky Linux 9.0
19.1.2. CentOS
19.1.3. Docker
19.1.4. Ubuntu/Debian
19.1.5. 源码安装
19.1.6. 二进制版本
19.1.7. Installing MySQL on Linux Using the MySQL Yum Repository
19.1.8. Firewall
19.1.9. Mac OS
19.1.10. MariaDB
19.1.11. Percona
19.2. MySQL Plugin
19.2.1. validate_password
19.2.2. MySQL Images manager
19.2.3. MySQL fifo
19.2.4. 内容输出到文本插件
19.3. Replication
19.3.1. Master Slave
19.3.2. Master Master(主主)
19.3.3. Semisynchronous Replication
19.3.4. multi-master replication
19.3.5. multi-source replication
19.3.6. 与复制有关的问题
19.3.7. GTID
19.4. MySQL Custer
19.4.1. Management node (MGM node)
19.4.2. Data node
19.4.3. SQL node
19.4.4. Starting
19.4.5. Shutdown
19.4.6. Testing
19.5. MySQL Proxy
19.5.1. Ubuntu
19.5.2. CentOS
19.6. MySQL Router
19.6.1. 安装 MySQL Router
19.6.2. 配置 MySQL Router
19.6.3. MySQL Router , Haproxy,LVS 的选择
19.7. my.cnf
19.7.1. bind-address
19.7.2. 禁用TCP/IP链接
19.7.3. 配置字符集
19.7.4. 最大链接数 max_connections
19.7.5. 默认引擎 storage-engine
19.7.6. max_allowed_packet
19.7.7. skip-name-resolve
19.7.8. timeout
19.7.9. 与复制有关的参数
19.7.10. 与 InnoDB 有关的配置项
19.7.11. EVENT 设置
19.7.12. 日志
19.7.13. MySQL 5.7 my.cnf 实例
19.7.14. Example for my.cnf
19.8. variables
19.8.1. 查询多个变量
19.8.2. time_zone
19.8.3. sql_mode
19.8.4. wait_timeout
19.8.5. table_lock_wait_timeout
19.8.6. low_priority_updates
19.8.7. collation_server
19.8.8. character_set
19.8.9. datadir
19.8.10. plugin_dir
19.8.11. storage_engine
19.8.12. timeout
19.8.13. max_connections
19.8.14. 自动提交 autocommit
19.9. Monitoring
19.9.1. Analysis and Optimization
19.9.2. Cacti
19.9.3. Monitoring MySQL with SNMP
20. Client and Utility Programs
20.1. mysql - the MySQL command-line tool
20.1.1. ~/.my.cnf
20.1.2. 屏幕输出到文件
20.1.3. 终端编码
20.1.4. Unix Socket
20.1.5. 重定向巧用
20.1.6. --sigint-ignore 忽略 Ctrl + C
20.1.7. mysql log
20.2. mysqldump - a database backup program
20.2.1. 备份数据库并压缩文件
20.2.2. 备份数据库/表
20.2.3. 备份到文件
20.2.4. 备份数据库,无结构,只有数据
20.2.5. 使用完整的insert插入数据
20.2.6. --extended-insert / --skip-extended-insert
20.2.7. --skip-lock-tables
20.2.8. --skip-add-locks
20.2.9. --where
20.2.10. 注释信息--comments /--skip-comments
20.2.11. 不导出注释信息
20.2.12. 字符集设置
20.3. mysqladmin - client for administering a MySQL server
20.3.1. reload
20.3.2. 更改密码
20.3.3. status
20.3.4. process list
20.4. myisamchk — MyISAM Table-Maintenance Utility
20.5. mysqlcheck — A Table Maintenance and Repair Program
20.6. mysqlslap - load emulation client
20.7. mysqldumpslow - Parse and summarize the MySQL slow query log.
20.8. mysql-shell
20.9.
20.10. MySQL慢查询日志(Slow Query Log)
20.10.1. MySQL 8.x
20.10.2. MySQL 5.x
20.11. mysql-admin
20.12. MySQL Workbench 数据库恢复
21. 数据库管理(Database Administration)
21.1. 用户管理(User Account Management)
21.1.1. 创建用户
21.1.2. 删除用户
21.1.3. 修改用户名
21.1.4. 修改密码
21.2. Access Privilege System
21.2.1. SHOW GRANTS
21.2.2. show privileges
21.2.3. Grant privileges
21.2.4. Revoke privileges
21.2.5. Show Privileges
21.2.6. MAX_QUERIES_PER_HOUR/MAX_UPDATES_PER_HOUR
21.2.7. Table Privileges
21.2.8. Column Privileges
21.3. 字符集转换
21.3.1. 转换 latin1 到 UTF-8
21.4. 重新整理AUTO_INCREMENT字段
21.5. 数据库内容替换
21.6. Kill 脚本
21.7. MySQL 时区管理
21.8. SHOW COMMAND
21.8.1. 查看版本
21.8.2. status
21.8.3. show processlist
21.8.4. 线程的使用情况
21.8.5. DATABASES
21.8.6. 排序统计信息
21.8.7. Key 状态
21.8.8. FUNCTION
21.8.9. PROCEDURE
21.8.10. TRIGGERS
21.8.11. EVENTS
21.8.12. 引擎(ENGINES)
21.8.13. 字符集(Collation)
21.8.14. SHOW GRANTS
21.8.15. validate_password
21.9. Maintenance 数据库维护
21.9.1. CHECK 检查表
21.9.2. ANALYZE 分析表
21.9.3. CHECKSUM
21.9.4. OPTIMIZE 优化表
21.9.5. REPAIR 修复
21.10. INFORMATION_SCHEMA
21.10.1. 查询表字段
21.10.2. 列出所有触发器
21.10.3. 查看表数据尺寸
21.11. Backup and Recovery
21.11.1. Import / Export
21.11.2. Snapshot Backup
22. DDL - Data Definition Language
22.1. 数据库管理(Database)
22.1.1. 创建数据库
22.1.2. 删除数据库
22.1.3. 修改数据库
22.1.4. 重命名数据库
22.1.5. 修改字符集
22.1.6. 查看数据库创建语句
22.2. 表管理(Table)
22.2.1. 数据类型
22.2.2. 基于现有表结构创建新空表
22.2.3. 基于已存在表创建新表
22.2.4. 修改表
22.2.5. 临时表
22.2.6. CHARACTER
22.2.7. DEFAULT
22.2.8. KEY
22.2.9. AUTO_INCREMENT 定义初始值
22.2.10. COMMENT
22.2.11. 修改表名
22.2.12. Engine 存储引擎
22.3. Partitioning
22.3.1. RANGE
22.3.2. LIST
22.3.3. HASH
22.3.4. KEY分区
22.3.5. Subpartitioning
22.3.6. 分区管理
22.3.7. EXPLAIN PARTITIONS
22.3.8. SHOW CREATE TABLE
22.3.9. INFORMATION_SCHEMA.partitions 表
22.3.10. 分区数据操作
22.4. Index
22.4.1. SHOW INDEX
22.4.2. CREATE INDEX
22.4.3. DROP INDEX
22.4.4. rebuild
22.5. 外键(Foreign Key)
22.5.1. FOREIGN KEY (RESTRICT)
22.6. 视图(View)
22.7. 存储过程(PROCEDURE)
22.7.1. 存储程序
22.7.2. EXECUTE 执行 SQL
22.7.3. PREPARE 传递参数
22.7.4. 存储过程返回数据
22.7.5. 结果集转JSON
22.7.6. 例子·过程返回结果
22.8. 函数
22.8.1. TIMESTAMP TO ISO8601
22.9. 触发器(Trigger)
22.9.1. create trigger
22.9.2. drop trigger
22.9.3. show triggers
22.9.4. EXAMPLE
22.10. 事件调度器(EVENT)
22.10.1. 启用 EVENT
22.10.2. 创建 EVENT
22.10.3. 禁用/启用
22.10.4. 查看 events
22.10.5. 删除 EVENT
22.10.6. EVENT 应用案例
23. DML (Data Manipulation Language)
23.1. INSERT
23.1.1. INSERT INTO ... SELECT
23.1.2. INSERT IGNORE
23.1.3. INSERT...ON DUPLICATE KEY UPDATE
23.2. REPLACE
23.3. DELETE
23.3.1. 删除重复数据
24. SQL Statement Syntax
24.1. DISTINCT
24.2. group by
24.3. HAVING
24.4. REGEXP
24.5. IN / NOT IN
24.6. ALL / Any
24.7. exists, not exists
24.8. UNION
24.8.1. UNION ALL
24.8.2. 两张表字段不对等解决方法
24.9. OUTFILE/LOAD DATA INFILE
24.9.1. Export data to CSV from MySQL
24.9.2. Import data from CSV file.
24.10. CASE Syntax
24.11. 查询结果放入变量
24.12. MySQL 专有命令
24.12.1. SQL_NO_CACHE
24.12.2. SIGNAL Syntax
24.13. SQL 92
25. Functions and Operators
25.1. COUNT
25.2. group_concat() 列传行
25.3. UUID()
25.4. String
25.4.1. LEFT/RIGHT
25.4.2. RPAD/LPAD
25.4.3. CONCAT
25.4.4. CONCAT_WS
25.4.5. 链接所有字段
25.4.6. GROUP_CONCAT
25.4.7. replace
25.4.8. SUBSTRING
25.4.9. SUBSTRING_INDEX
25.4.10. AES_ENCRYPT / AES_DECRYPT
25.5. Date and Time
25.5.1. year/month/day hour:minite:second
25.5.2. Unix time
25.5.3. DATE_FORMAT
25.5.4. DATE_SUB/DATE_ADD
25.5.5. datediff / timediff
25.6. 数值函数
25.6.1. cast 类型转换
25.6.2. truncate 保留小数位数
25.6.3. MOD 求余
25.7. Control Flow Functions
26. DCL (Data Control Language)
26.1. 锁
26.1.1. 共享锁
26.1.2. 排他锁
26.1.3. 锁
26.1.4. 锁等待与超时
26.2. 事务处理和锁定语句
26.2.1. 事务隔离级别
26.2.2. 事务所用到的表
26.2.3. 解决更新冲突
26.2.4. 共享锁
26.2.5. SAVEPOINT
27. Optimization
27.1. Limit 状态
27.2. 使用 Btrfs 文件系统存储mysql数据
27.3. 打开表的数量
27.4. Buffering and Caching
27.4.1. Query Cache SELECT Options
27.5. where 优化
27.6. SHOW PROFILE Syntax SQL性能分析器
27.7. PROCEDURE ANALYSE()
28. MySQL Connectors
28.1. JDBC
28.2. ODBC
28.3. MySQL native driver for PHP - mysqlnd
28.4. python-mysqldb
29. MySQL GUI/Web Manager
29.1. HeidiSQL
29.2. Toad for MySQL Freeware
29.3. phpMyAdmin - MySQL web administration tool
29.4. Maatkit Essential command-line utilities for MySQL
30. Miscellaneous
30.1. Multi-Master Replication Manager for MySQL
30.2. MHA
30.3. HandlerSocket
30.4. Maatkit
30.5. Mroonga
30.6. Amoeba
31. FAQ
31.1. Reset root password 重置MySQL root密码
31.1.1. MySQL 5.7.x
31.1.2. MySQL 8.0
31.2. 查看错误代码
31.2.1. ERROR 1153 (08S01) at line 3168: Got a packet bigger than 'max_allowed_packet' bytes
31.2.2. ERROR 1129 (00000): Host 'XXXXXX' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
31.3. 临时表是否需要建索引
31.4. [Warning] Changed limits: max_open_files: 5000 (requested 20480)
31.5. Table 'performance_schema.session_variables' doesn't exist
31.6. SQL Error (1038): Out of sort memory, consider increasing server sort buffer size
31.7. this is incompatible with sql_mode=only_full_group_by
31.8. ERROR 1071 (42000) at line 25: Specified key was too long; max key length is 767 bytes
31.9. ERROR 1086 (HY000): File '/var/lib/mysql-files/order.txt' already exists
31.10. ERROR 1114 (HY000): The table 'your_table' is full
31.11. Error Code: 1146. Table 'test.CACHE_UPDATE' doesn't exist
31.12. Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column.
31.13. ERROR 1273 (HY000) at line 3364: Unknown collation: 'utf8mb4_0900_ai_ci'
31.14. ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
31.15. ERROR 1364: 1364: Field 'id' doesn't have a default value
31.16. Error Code: 1292. Incorrect datetime value: '0000-00-00 00:00:00' for column 'create_time' at row 95692
31.17. ERROR 1415: Not allowed to return a result set from a trigger
31.18. ERROR 1503 (HY000): A PRIMARY KEY must include all columns in the table's partitioning function
31.19. ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
31.20. ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
31.21. ERROR 1840 (HY000) at line 24: @@GLOBAL.GTID_PURGED can only be set when @@GLOBAL.GTID_EXECUTED is empty.
31.22. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
31.23. ERROR 2013 (HY000): Lost connection to MySQL server during query
31.24. ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory
31.25. ERROR 3024 (HY000): Query execution was interrupted, maximum statement execution time exceeded
31.26. Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such fileor directory
31.27. com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Public Key Retrieval is not allowed
31.28. mysqldump: Couldn't execute 'SELECT COLUMN_NAME,
31.29. this is incompatible with sql_mode=only_full_group_by
31.30. mysqldump: [Warning] Using a password on the command line interface can be insecure.
31.31. mysql: [Warning] Using a password on the command line interface can be insecure.
31.32. 时间自动被加一秒