ログ出力先変更
vi /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 general_log=0 general_log_file=/var/log/mysql/query.log [mysqld_safe] log-error=/var/log/mysql/mysqld.log #<==ここを変更 pid-file=/var/run/mysqld/mysqld.pid
mysql再起動
[root@localhost log]# sudo service mysqld restart mysqld を停止中: [ OK ] mysqld を起動中: [ OK ]
ログ確認
[root@localhost log]# tail /var/log/mysql/mysqld.log 161114 09:35:27 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 161114 9:35:27 InnoDB: Initializing buffer pool, size = 8.0M 161114 9:35:27 InnoDB: Completed initialization of buffer pool 161114 9:35:27 InnoDB: Started; log sequence number 0 44233 161114 9:35:27 [Note] Event Scheduler: Loaded 0 events 161114 9:35:27 [Note] /usr/libexec/mysqld: ready for connections. Version: '5.1.73' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution [root@localhost log]#
※socketエラーは調査中
クエリーログ
クエリーのログを出力したい場合は、下記のように設定する。
$ sudo vi /etc/my.cnf ・・・ [mysqld] ・・・ general_log=1 general_log_file=/var/log/mysql/query.log
クエリーのログが出力される。
[root@localhost log]# tail /var/log/mysql/mysqld.log 161114 09:35:27 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 161114 9:35:27 InnoDB: Initializing buffer pool, size = 8.0M 161114 9:35:27 InnoDB: Completed initialization of buffer pool 161114 9:35:27 InnoDB: Started; log sequence number 0 44233 161114 9:35:27 [Note] Event Scheduler: Loaded 0 events 161114 9:35:27 [Note] /usr/libexec/mysqld: ready for connections. Version: '5.1.73' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution [root@localhost log]# tail /var/log/mysql/query.log 4 Query SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (241) ORDER BY meta_id ASC 4 Query SELECT * FROM wp_posts WHERE ID = 241 LIMIT 1 4 Query SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (241) ORDER BY meta_id ASC 4 Query SELECT * FROM wp_posts WHERE ID = 244 LIMIT 1 4 Query SELECT * FROM wp_posts WHERE ID = 244 LIMIT 1 4 Query SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (244) ORDER BY meta_id ASC 4 Query SELECT option_value FROM wp_options WHERE option_name = 'jpsq_sync_checkout' 4 Query UPDATE wp_options SET option_value = '0:0' WHERE option_name = 'jpsq_sync_checkout' 4 Query UPDATE `wp_options` SET `option_value` = '1479083179', `autoload` = 'yes' WHERE `option_name` = 'jetpack_next_sync_time_sync' 4 Quit [root@localhost log]#
[amazonjs asin=”4295000191″ locale=”JP” title=”やさしく学べるMySQL運用・管理入門【5.7対応】”]
コメント