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