Mysql 学习笔记
Mysql 命令行比较常用的程序
- mysqld mysql的常驻后台程序,这个不用多记录了
- mysql_safe 说是用这个来启动mysql会更安全些,其实也是调用了mysqld
- mysql.server 据说这个启动mysql更强大吧,功能更多,实际调用的是mysql_safe,这个玩意反正我用docker装的数据库里面没看到,官方文档就说是原生带过来的,反正我没看到
- mysql mysql client
- mysqladmin 一个管理相关的mysql客户端
- mysqlcheck 可以修复数据库的问题啊,对数据库做健康检查啊之类的
- mysqldump 把数据库导出到文件
- mysqlpump 一个比mysqldump更高级的数据库导出程序
- mysqlimport 把数据库的dump文件导入的程序,实际上是调用了LOAD DATA INFILE命令
- mysqlshow 展示数据库信息的客户端
- mysqlslap mysql的一个压测工具,自带的原生的,这个玩意很好很强大
- mysqlbinlog 这个是查看mysql bin log的工具
- mysqldumpslow mysql slow log的分析工
- mysql_config_editor 加密保存,编辑登录信息的客户端工具
- my_print_defaults 打印配置文件里面对应配置组的配置
其余的详见 https://dev.mysql.com/doc/refman/5.7/en/programs-overview.html
Mysql 配置
-
mysqld reads options from the [mysqld] and [server] groups. mysqld_safe reads options from the [mysqld], [server], [mysqld_safe], and [safe_mysqld] groups. mysql.server reads options from the [mysqld] and [mysql.server] groups. An embedded MySQL server usually reads options from the [server], [embedded], and [xxxxx_SERVER] groups, where xxxxx is the name of the application into which the server is embedded.
-
Global and session system variables are related as follows:
-
When the server starts, it initializes each global variable to its default value. These defaults can be changed by options specified on the command line or in an option file. (See Section 5.2.3, “Specifying Program Options”.)
-
The server also maintains a set of session variables for each client that connects. The client’s session variables are initialized at connect time using the current values of the corresponding global variables. For example, a client’s SQL mode is controlled by the session sql_mode value, which is initialized when the client connects to the value of the global sql_mode value.
For some system variables, the session value is not initialized from the corresponding global value; if so, that is indicated in the variable description.
-
设置 global variables 需要管理员权限,某些 session variable 的设置也是需要管理员权限的(这个在变量的使用说明里面是有明确说明的)
-
某些session variable的默认值是从global variable那里赋值过来的,当global variable 在数据库运行时被改变,已经被初始化过的的session variable不会再改变它的值,这个新的global variable 的值,只对新链接上的变量有用
-
严格模式,里面有IGNORE关键字的用法
Mysql 安全
Making MySQL Secure Against Attackers : 讲了为什么不能用root权限来启动mysqld啊之类的 Security-Related mysqld Options and Variables How to Run MySQL as a Normal User Security Issues with LOAD DATA LOCAL Client Programming Security Guidelines 讲一些客户端执行sql语句之类的安全,包括可能引起严重性能问题的操作 The MySQL Access Privilege System