mysql远程访问慢的解决小妙招

最近搞了一个数据库连接池,连接服务器时发现半天才创建一个连接,跟崩豆子一样,我的天啊。。。 脑袋各种黑线,于是找问题所在.好在google出了原因,原来每次访问mysql就会试图去解析来访问的机器的domain name,擦,说的有道理啊,那就是修改配置吧,在mysqld.cnf里面加入skip-name-resolve跳过解析。

vi /etc/mysql/mysql.conf.d/mysqld.cnf

[mysqld_safe]
socket          = /var/run/mysqld/mysqld.sock
nice            = 0

[mysqld]
#
# * Basic Settings
#
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
lc-messages-dir = /usr/share/mysql
skip-external-locking
skip-name-resolve

重启服务

/etc/init.d/mysql restart

再次运行

lilei@JZ-server-53:~/work/p2p/Linux-c-epoll/server$ cur:1024
max:4096
create db pool success
create db pool success
create db pool success
create db pool success
create db pool success
create db pool success
create db pool success
create db pool success
create db pool success
create db pool success
create db pool success
create db pool success
create db pool success
create db pool success
create db pool success
index = 0
index = 1
index = 2
index = 3
index = 4
index = 5
index = 6
index = 7
index = 8
index = 9
index = 10
index = 11
index = 12
index = 13
index = 14
bind config port 9009 success.

我的乖乖,就是牛叉,速度刚刚的!!!

你可能感兴趣的:(数据库)