mysql开启binglog、慢查询日志、编码

binlog

# vi /etc/my.cnf
[mysqld] 
# 开启 binlog
log-bin=mysql-bin
binlog-format=Row
server-id=1

查询:mysqlbinlog --no-defaults --base64-output=decode-rows -v mysql-bin.000003

slowlog

[mysqld] 
# 开启 slowlog
log_output=file
slow_query_log=on
slow_query_log_file = /tmp/mysql-slow.log
log_queries_not_using_indexes=on
long_query_time = 1

【检查】
mysql> show variables like '%quer%';
+----------------------------------------+------------------------------------+
| Variable_name                          | Value                              |
+----------------------------------------+------------------------------------+
| binlog_rows_query_log_events           | OFF                                |
| ft_query_expansion_limit               | 20                                 |
| have_query_cache                       | YES                                |
| log_queries_not_using_indexes          | ON                                 |
| log_throttle_queries_not_using_indexes | 0                                  |
| long_query_time                        | 1.000000                           |
| query_alloc_block_size                 | 8192                               |
| query_cache_limit                      | 1048576                            |
| query_cache_min_res_unit               | 4096                               |
| query_cache_size                       | 8388608                            |
| query_cache_type                       | OFF                                |
| query_cache_wlock_invalidate           | OFF                                |
| query_prealloc_size                    | 8192                               |
| slow_query_log                         | ON                                 |
| slow_query_log_file                    | /tmp/mysql-slow.log |
+----------------------------------------+------------------------------------+

编码utf-8

1、查询
mysql>  show variables like 'character_set_%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | latin1                     |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

2、配置:vi /etc/my.cnf

3、[mysqld]添加
	  character_set_server=utf8

4、重启mysql服务。
    停止命令:systemctl stop mysqld.service
    启动命令:systemctl start mysqld.service

重启

service mysql restart
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值