

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# mysql 属性
<a name="attributes-recipes-mysql"></a>

**重要**  
该 AWS OpsWorks Stacks 服务于 2024 年 5 月 26 日终止，新客户和现有客户均已禁用。我们强烈建议客户尽快将其工作负载迁移到其他解决方案。如果您对迁移有疑问，请通过 re [AWS : Post 或通过 Pre](https://repost.aws/) mium Su [AWS pp](https://aws.amazon.com/support) ort 与 AWS 支持 团队联系。

**注意**  
这些属性仅在 Linux 堆栈上可用。

[`mysql` 属性](https://github.com/aws/opsworks-cookbooks/blob/release-chef-11.10/mysql/attributes/server.rb)指定 [MySQL](http://www.mysql.com/) 主配置。有关更多信息，请参阅[服务器系统变量](http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html)。有关如何覆盖内置属性以指定自定义值的更多信息，请参阅 [覆盖属性](workingcookbook-attributes.md)。


****  

|  |  |  | 
| --- |--- |--- |
| [basedir ](#attributes-recipes-mysql-basedir) | [bind\$1address ](#attributes-recipes-mysql-bind) | [客户端 ](#attributes-recipes-mysql-clients) | 
| [conf\$1dir ](#attributes-recipes-mysql-conf) | [confd\$1dir ](#attributes-recipes-mysql-confd) | [datadir ](#attributes-recipes-mysql-datadir) | 
| [grants\$1path ](#attributes-recipes-mysql-grants) | [mysql\$1bin ](#attributes-recipes-mysql-bin) | [mysqladmin\$1bin ](#attributes-recipes-mysql-admin-bin) | 
| [pid\$1file ](#attributes-recipes-mysql-pid) | [端口 ](#attributes-recipes-mysql-port) | [root\$1group ](#attributes-recipes-mysql-group) | 
| [server\$1root\$1password ](#attributes-recipes-mysql-pwd) | [球座 ](#attributes-recipes-mysql-socket) | [tunable 属性](#attributes-recipes-mysql-tunable) | 

**basedir **  <a name="attributes-recipes-mysql-basedir"></a>
基目录 (字符串)。默认值为 `'/usr'`。  

```
node[:mysql][:basedir]
```

**bind\$1address **  <a name="attributes-recipes-mysql-bind"></a>
MySQL 侦听的地址 (字符串)。默认值为 `'0.0.0.0'`。  

```
node[:mysql][:bind_address]
```

**客户端 **  <a name="attributes-recipes-mysql-clients"></a>
客户端列表 (字符串列表)。  

```
node[:mysql][:clients]
```

**conf\$1dir **  <a name="attributes-recipes-mysql-conf"></a>
包含配置文件的目录 (字符串)。默认值如下所示：  
+ Amazon Linux 和 RHEL: `'/etc'`
+ Ubuntu: `'/etc/mysql'`

```
node[:mysql][:conf_dir]
```

**confd\$1dir **  <a name="attributes-recipes-mysql-confd"></a>
包含额外配置文件的目录 (字符串)。默认值为 `'/etc/mysql/conf.d'`。  

```
node[:mysql][:confd_dir]
```

**datadir **  <a name="attributes-recipes-mysql-datadir"></a>
数据目录 (字符串)。默认值为 `'/var/lib/mysql'`。  

```
node[:mysql][:datadir]
```

**grants\$1path **  <a name="attributes-recipes-mysql-grants"></a>
授权表位置 (字符串)。默认值为 `'/etc/mysql_grants.sql'`。  

```
node[:mysql][:grants_path]
```

**mysql\$1bin **  <a name="attributes-recipes-mysql-bin"></a>
mysql 二进制文件位置 (字符串)。默认值为 `'/usr/bin/mysql'`。  

```
node[:mysql][:mysql_bin]
```

**mysqladmin\$1bin **  <a name="attributes-recipes-mysql-admin-bin"></a>
mysqladmin 位置 (字符串)。默认值为 `'/usr/bin/mysqladmin'`。  

```
node[:mysql][:mysqladmin_bin]
```

**pid\$1file **  <a name="attributes-recipes-mysql-pid"></a>
包含守护程序进程 ID 的文件 (字符串)。默认值为 `'/var/run/mysqld/mysqld.pid'`。  

```
node[:mysql][:pid_file]
```

**端口 **  <a name="attributes-recipes-mysql-port"></a>
服务器侦听的端口 (数字)。默认值为 `3306`。  

```
node[:mysql][:port]
```

**root\$1group **  <a name="attributes-recipes-mysql-group"></a>
根组 (字符串)。默认值为 `'root'`。  

```
node[:mysql][:root_group]
```

**server\$1root\$1password **  <a name="attributes-recipes-mysql-pwd"></a>
服务器的根密码 (字符串)。默认值将随机生成。  

```
node[:mysql][:server_root_password]
```

**球座 **  <a name="attributes-recipes-mysql-socket"></a>
套接字文件的位置 (字符串)。默认值为 `'/var/lib/mysql/mysql.sock'`。默认值如下所示：  
+ Amazon Linux 和 RHEL: `'/var/lib/mysql/mysql.sock'`
+ Ubuntu: `'/var/run/mysqld/mysqld.sock'`

```
node[:mysql][:socket]
```

**tunable 属性**  <a name="attributes-recipes-mysql-tunable"></a>
tunable 属性用于优化性能。    
****    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/opsworks/latest/userguide/attributes-recipes-mysql.html)  
**back\$1log **  <a name="attributes-recipes-mysql-tunable-back"></a>
最大未完成请求数 (字符串)。默认值为 `'128'`。  

```
node[:mysql][:tunable][:back_log]
```  
**innodb\$1additional\$1mem\$1pool\$1size **  <a name="attributes-recipes-mysql-tunable-mem"></a>
[Innodb](http://dev.mysql.com/doc/refman/5.5/en/innodb-storage-engine.html) 用于存储内部数据结构的池的大小 (字符串)。默认值为 `'20M'`。  

```
node[:mysql][:tunable][:innodb_additional_mem_pool_size]
```  
**innodb\$1buffer\$1pool\$1size **  <a name="attributes-recipes-mysql-tunable-buffer"></a>
[Innodb](http://dev.mysql.com/doc/refman/5.5/en/innodb-storage-engine.html) 缓冲池的大小 (字符串)。属性值由 OpsWorks Stacks 设置并取决于实例类型，但您可以使用自定义 JSON 或自定义属性文件来[覆盖](workingcookbook-attributes.md)该值。  

```
node[:mysql][:tunable][:innodb_buffer_pool_size]
```  
**innodb\$1flush\$1log\$1at\$1trx\$1commit **  <a name="attributes-recipes-mysql-tunable-flush"></a>
[Innodb](http://dev.mysql.com/doc/refman/5.5/en/innodb-storage-engine.html) 刷新日志缓冲区的频率 (字符串)。默认值为 `'2'`。有关更多信息，请参阅 [innodb\$1flush\$1log\$1at\$1trx\$1commit](http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_flush_log_at_trx_commit)。  

```
node[:mysql][:tunable][:innodb_flush_log_at_trx_commit]
```  
**innodb\$1lock\$1wait\$1timeout **  <a name="attributes-recipes-mysql-tunable-lock"></a>
[Innodb](http://dev.mysql.com/doc/refman/5.5/en/innodb-storage-engine.html) 事务等待行锁的最长时间 (秒) (字符串)。默认值为 `'50'`。  

```
node[:mysql][:tunable][:innodb_lock_wait_timeout]
```  
**key\$1buffer **  <a name="attributes-recipes-mysql-tunable-key"></a>
索引缓冲区大小 (字符串)。默认值为 `'250M'`。  

```
node[:mysql][:tunable][:key_buffer]
```  
**log\$1slow\$1queries **  <a name="attributes-recipes-mysql-tunable-slow"></a>
慢速查询日志文件的位置 (字符串)。默认值为 `'/var/log/mysql/mysql-slow.log'`。  

```
node[:mysql][:tunable][:log_slow_queries]
```  
**long\$1query\$1time **  <a name="attributes-recipes-mysql-tunable-long"></a>
将查询指定为长时间运行查询所需的时间 (秒) (字符串)。默认值为 `'1'`。  

```
node[:mysql][:tunable][:long_query_time]
```  
**max\$1allowed\$1packet **  <a name="attributes-recipes-mysql-tunable-packet"></a>
允许的最大数据包大小 (字符串)。默认值为 `'32M'`。  

```
node[:mysql][:tunable][:max_allowed_packet]
```  
**max\$1connections **  <a name="attributes-recipes-mysql-tunable-connections"></a>
最大并发客户端连接数 (字符串)。默认值为 `'2048'`。  

```
node[:mysql][:tunable][:max_connections]
```  
**max\$1heap\$1table\$1size **  <a name="attributes-recipes-mysql-tunable-heap"></a>
用户创建的 `MEMORY` 表的最大大小 (字符串)。默认值为 `'32M'`。  

```
node[:mysql][:tunable][:max_heap_table_size]
```  
**net\$1read\$1timeout **  <a name="attributes-recipes-mysql-tunable-net-read"></a>
等待来自连接的更多数据的时长 (秒) (字符串)。默认值为 `'30'`。  

```
node[:mysql][:tunable][:net_read_timeout]
```  
**net\$1write\$1timeout **  <a name="attributes-recipes-mysql-tunable-net-write"></a>
等待数据块写入连接的时长 (秒) (字符串)。默认值为 `'30'`。  

```
node[:mysql][:tunable][:net_write_timeout]
```  
**query\$1cache\$1limit **  <a name="attributes-recipes-mysql-tunable-cache-limit"></a>
单个缓存查询的最大大小 (字符串)。默认值为 `'2M'`。  

```
node[:mysql][:tunable][:query_cache_limit]
```  
**query\$1cache\$1size **  <a name="attributes-recipes-mysql-tunable-cache-size"></a>
查询缓存大小 (字符串)。默认值为 `'128M'`。  

```
node[:mysql][:tunable][:query_cache_size]
```  
**query\$1cache\$1type **  <a name="attributes-recipes-mysql-tunable-cache-type"></a>
查询缓存类型 (字符串)。可能的值如下所示：  
+ `'0'`：不缓存或检索缓存数据。
+ `'1'`：缓存不以 `SELECT SQL_NO_CACHE` 开头的语句。
+ `'2'`：缓存以 `SELECT SQL_CACHE` 开头的语句。
默认值为 `'1'`。  

```
node[:mysql][:tunable][:query_cache_type]
```  
**thread\$1cache\$1size **  <a name="attributes-recipes-mysql-tunable-thread-cache"></a>
缓存以便重复使用的客户端线程数 (字符串)。默认值为 `'8'`。  

```
node[:mysql][:tunable][:thread_cache_size]
```  
**thread\$1stack **  <a name="attributes-recipes-mysql-tunable-thread-stack"></a>
每个线程的堆栈大小 (字符串)。默认值为 `'192K'`。  

```
node[:mysql][:tunable][:thread_stack]
```  
**wait\$1timeout **  <a name="attributes-recipes-mysql-tunable-wait"></a>
等待非交互式连接的时长 (秒)。默认值为 `'180'` (字符串)。  

```
node[:mysql][:tunable][:wait_timeout]
```  
**table\$1cache **  <a name="attributes-recipes-mysql-tunable-table"></a>
打开的表的数量 (字符串)。默认值为 `'2048'`。  

```
node[:mysql][:tunable][:table_cache]
```