Mysql连接花费了太多时间

时间:2013-09-09 08:23:04

标签: mysql database

我正在使用mysql 5.5.32。下面是我的配置文件(my.cnf)......

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mysqld according to the
# instructions in http://fedoraproject.org/wiki/Systemd

innodb_file_per_table=1
skip-name-resolve
innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend

log-error=/var/log/mysql/mysql_error.log
long_query_time=1
slow_query_log=1
log-warnings=2
slow-query-log-file=/var/log/mysql/log-slow-queries.log

#starting
#old_passwords=1

#log-bin
#binlog-do-db=<database name>  # input the database which should be replicated
#binlog-ignore-db=mysql            # input the database that should be ignored for replication
#binlog-ignore-db=test


server-id=1
#ending

open_files_limit= 2000
thread_cache_size = 64

query_cache_limit=400M
query_cache_size = 400M
query_cache_type=1
[mysql.server]
user=mysql
basedir=/var/lib

[mysqld_safe]
#log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

当我重新启动mysql时,我很快就进入了mysql控制台。一段时间后,当我尝试进入mysql控制台时,它需要大约15-20秒。

我使用命令 show processlist 来检查查询,但没有加载mysql服务器。

为什么花费太多时间?如何追踪错误是什么?

1 个答案:

答案 0 :(得分:0)

使用这句话log-slow-queries=/var/log/mysql/log-slow-queries.log代替slow-query-log-file=/var/log/mysql/log-slow-queries.log我认为这是你在日志文件中没有看到任何内容的问题

确保您拥有文件

touch /var/log/mysql/log-slow-queries.log
chown mysql.mysql -R /var/log/mysql

我从这里得到这个想法:http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html,所以看一看有用的东西