3

I'm running MySQL 5.6 (64-bit) on Windows 7. I'm testing a DB recently upgraded from MySQL 5.0 on 32-bit Windows 7. (I also copied my.ini, with a few changes)

I'm finding that it takes a very long time to establish a connection (on the order of 1 second). As an example, I created a very simple SQL script:

select 1 as n;

I then ran this in a batch file 10 times which took 10 seconds to complete:

mysql -h localhost -u root -D myschema 0< myscript.sql

(Yes, there is no password here, this is a test DB listening only to 127.0.0.1)

Anyone have an idea why this is so very slow? (See my.ini below)

[client]
port=3306
[mysql]
default-character-set=latin1
[mysqld]
port=3306
bind-address=127.0.0.1
basedir="C:/Program Files/MySQL/mysql-5.6.10-winx64/"
datadir=C:/DATA
character-set-server=latin1
default-storage-engine=myisam
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
max_connections=100
query_cache_size=0
table_open_cache=256
tmp_table_size=18M
thread_cache_size=8
myisam_max_sort_file_size=100G
myisam_sort_buffer_size=35M
key_buffer_size=25M
read_buffer_size=64K
read_rnd_buffer_size=256K
sort_buffer_size=256K
innodb_additional_mem_pool_size=2M
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=1M
innodb_buffer_pool_size=47M
innodb_log_file_size=24M
innodb_thread_concurrency=8
log-bin=c:/data/mysql/binarylog
max_binlog_size=1024M
enable-named-pipe
slow_query_log=
expire_logs_days=90
4

1 回答 1

4

嗬!看来这是个骗子。看:

为什么连接到 MySQL 服务器这么慢?

https://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow

我在 64 位机器而不是 32 位机器上启用了 IPv6。当我连接以下备用字符串时,事情会快得多:

mysql -h 127.0.0.1 -u root -D myschema 0< myscript.sql

仍然不确定为什么会发生这种情况,但至少有一个解决方法!唉,可怜localhost我很了解他。

编辑:对 my.ini 的以下更改允许localhost在脚本和连接字符串中使用:

bind-address=::1

注意:绑定::ffff:127.0.0.1localhost似乎没有帮助。我阅读了有关将 IPv6 和 IPv4 地址绑定到 MySQL 服务器的信息,因此所有 3 个连接字符串都可以正常工作(例如-h ::1,、、-h 127.0.0.1-h localhost。但是,我一次只能让其中一两个客户端字符串工作。

EDIT2:以下列方式绑定:

bind-address=*

完全解决了这个问题,IPv4 和 IPv6 客户端都可以连接。唯一的缺点是现在允许远程连接。我还没有找到一种方法来使用带有localhost限制的 TCP 并同时绑定127.0.0.1 ::1.

于 2013-07-23T20:57:29.180 回答