Posted by: Bobby Allen on: November 2, 2007
Now a few of my projects are getting much bigger and the need for having dedicated Database servers are now more appealing than ever.
With MySQL when setting it up I noticed that when trying to access a remote database from an application server, it would takes ages to respond/connect to it.
After searching around the web, I have found what appears to be the solution…
It appears to be that the MySQL server lookups hostnames for authentication EVEN IF you are using for example: remoteuser@231.23.65.23 so to speed up remote connections to your remote database servers try adding the following line…
skip-name-resolve
To your MySQL configuration file (my.ini/my.cnf) and then be sure to reload (restart) the MySQL database server. The ‘[mysqld]‘ section of the my.cnf file now looks like this:
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-locking
skip-name-resolve
From Microsoft Windows this can be done from the ‘Services’ window in ‘Administrative tools’ or in Debian/Ubuntu entering this command:
/etc/init.d/mysql restart
The above addition will ONLY work if you are using IP Address or ‘%’ for the Database User accounts and will ofcourse disable the ability to use user accounts with the hostname eg. remoteuser@server2.example.com.
[...] 为了避免缓慢的远程连接,还必须在[mysqld]段加上: skip-name-resolve [...]
[...] Kemudian script PHP untuk uji cobanya adalah sebagai berikut: <?php var_dump(mysql_connect('192.168.1.8','nyoba','password')); mysql_close(); ?> Script ini disimpan dan dijalankan pada host web server. Ternyata koneksi berhasil. Sayangnya, proses eksekusi script berjalan begitu lambat. Padahal ini masih pada jaringan lokal tapi kok pelan bener ya? Abis searching di Internet, terus nemu artikel ini. [...]
Thank you so much! Me and my dev team are extremely grateful.
Thank you!!!
Thank you very much. It helps a lot !
Hi,
I tried this on linux, here are the results from my web application.
There are 10 pc’s 6 with windows 7 and 4 with winxp. Out of the 6 win7 3 have a slow connection and out of 4 winxp 2 has slow connection.
So out of 10 pc’s 5 pc’s access the application slowly. Is it to do with the configuration of mysql or the DNS or the network(this is ruled out as they all are connected to the same hub).
[...] Script PHP ini disimpan dan dijalankan pada host web server. Ternyata koneksi berhasil. Sayangnya, proses eksekusi script berjalan begitu lambat. Padahal ini masih pada jaringan lokal tapi kok pelan bener ya? Abis searching di Internet, terus nemu artikel ini. [...]
May 16, 2008 at 11:08 am
Thanks! This helped me a lot. I had suffered from slow connections after changing the MySQL server.