必知必会。
部署
外网连不上
MySQL 配置中有一项 bing-address
,表示 MySQL 监听的 IP。
设置为:
1 | bind-address = 0.0.0.0 |
可以监听所有 IP。
用户和权限
1 | CREATE USER 'user1'@'%' IDENTIFIED BY '123456'; |
授予权限:
1 | GRANT SELECT ON employees.* TO 'user1'@'%' |
identifier
sql - When to use single quotes, double quotes, and backticks in MySQL - Stack Overflow
MySQL :: MySQL 8.0 Reference Manual :: 9.2 Schema Object Names
MySQL :: MySQL 8.0 Reference Manual :: 5.1.11 Server SQL Modes
区分大小写问题
网上一个回答这么说:
在Linux下:
1、数据库名与表名是严格区分大小写的;
2、表的别名是严格区分大小写的;
3、列名与列的别名在所有的情况下均是忽略大小写的;
4、变量名也是严格区分大小写的;在Windows下:
全部不区分大小写
但是在 Windows 下如果想区分大小写,可以通过修改参数的方式实现。
命名规约
Is there a naming convention for MySQL? - Stack Overflow
mysql - Are there any published coding style guidelines for SQL? - Stack Overflow
MySQL :: MySQL Internals Manual :: 26.1.1 Coding Style
SQL style guide by Simon Holywell
常用文档
MySQL :: MySQL 5.7 Reference Manual :: 13.1.18 CREATE TABLE Statement
MySQL :: MySQL 5.7 Reference Manual :: 9.2 Schema Object Names
MySQL :: MySQL 5.7 Reference Manual :: 22.6.1 Partitioning Keys, Primary Keys, and Unique Keys
MySQL :: MySQL 5.7 Reference Manual :: 14.23 InnoDB Limits
MySQL :: MySQL 5.7 Reference Manual :: 11.7 Data Type Storage Requirements
MySQL :: MySQL 8.0 Reference Manual :: 10.3.5 Column Character Set and Collation
MySQL :: MySQL 5.7 Reference Manual :: 5.4.4 The Binary Log
其他
mysql批量插入数据,一次插入多少行数据效率最高?_慕课手记
一个很好用的在线二维码格式化网站
Format SQL Statements Online - sqlformat.org
可以重新为命令和标识符选择大小写。
数据迁移
官方文档中对于数据迁移的一些指导。
MySQL :: MySQL Workbench Manual :: 10 Database Migration Wizard
MySQL :: MySQL Workbench Manual :: 10.6.4 PostgreSQL Type Mapping