![从 MySQL 4 升级到 Mysql 5 - 相同的 my.cnf - 大量随机断开连接](https://linux22.com/image/548830/%E4%BB%8E%20MySQL%204%20%E5%8D%87%E7%BA%A7%E5%88%B0%20Mysql%205%20-%20%E7%9B%B8%E5%90%8C%E7%9A%84%20my.cnf%20-%20%E5%A4%A7%E9%87%8F%E9%9A%8F%E6%9C%BA%E6%96%AD%E5%BC%80%E8%BF%9E%E6%8E%A5.png)
我最近从 MySQL4 迁移到了 MySQL5(我们的一些应用程序需要 MySQL4,但我们最终将其替换掉了)
从那时起,我遇到了很多类似的问题:-
connect() failed: Lost connection to MySQL server at 'reading initial communication packet', system error: 0
是的,这是系统错误 0 — “成功”。
我不知道为什么会发生这种情况 - 但想找出原因
这是我的(已清理的)my.cnf
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/english
skip-external-locking
key_buffer = 1048M
max_allowed_packet = 16M
thread_stack = 2M
thread_cache_size = 16384
sort_buffer_size = 256K
read_buffer_size = 2M
read_rnd_buffer_size = 256K
tmp_table_size = 512M
max_heap_table_size = 512M
query_cache_size = 512M
thread_concurrency = 16
set-variable = table_cache=16384
max_connections = 500
wait_timeout = 3600
innodb_buffer_pool_size = 1024M
innodb_additional_mem_pool_size = 8M
innodb_lock_wait_timeout = 50
innodb_flush_method=O_DIRECT
innodb_log_buffer_size = 8M
innodb_thread_concurrency = 8
innodb_file_per_table=1
query_cache_limit = 1024M
query_cache_size = 512M
query_cache_type = 1
server-id = 9
log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
expire_logs_days = 3
skip-bdb
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
prompt = (\u@atlas) [\d]>\\_
[isamchk]
key_buffer = 16M
!includedir /etc/mysql/conf.d/
编辑我更改了上面的 my.cnf - 我刚刚意识到它是来自旧服务器的!另外 - 这是 5.0,而不是 5.1
答案1
首先,删除这里发布的“skip-bdb”行:Mysql-Server-5.1升级问题
答案2
似乎有一个详细的错误报告这解释了这个错误,并提出了增加参数的可能解决方案connect_timeout
。