Fix 2003 Can ' t connect to MySQL server on ' localhost ' (10048)

Source: Internet
Author: User

2003
Can ' t connect to MySQL server on ' localhost ' (10048)
Typically seen in Windows 2003 servers using MySQL.
Reason for the occurrence of the error:

The first reason:
The application needs to quickly release and create new connections, but lower throughput due to the presence of connections in time_wait that exceed the default values.
Solution:
Two windows registry entries that are closely related to this error: TcpTimedWaitDelay and MaxUserPort values.
TcpTimedWaitDelay determines the time that TCP/IP must pass before it can release a closed connection and reuse its resources. This interval between closing and releasing is known as the time_wait state or twice times the maximum segment life cycle (2MSL) state. During this time, reopening the connection to the client and the server costs less than establishing a new connection. Reducing this value allows TCP/IP to release closed connections more quickly, providing more resources for new connections.
MaxUserPort determines the maximum number of ports that TCP/IP can specify when requesting any available user ports from the system. If you establish a TCP connection with a maximum port connection greater than 5000, the local computer responds with the following error message Wsaenobufs (10055): Because the system lacks sufficient buffers or because the queue is full, the socket operation cannot be performed, resulting in an application 10048 error.
Open Registry Editor regedit
TcpTimedWaitDelay settings: Found
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters the registry subkey and creates a key namedNew REG_DWORD value for TcpTimedWaitDelaySet this value to decimal 30, and hexadecimal to 0x0000001e the value wait time will be 30 seconds. Default value for this item: 0xF0 (16 binary), wait time set to 240 seconds
MaxUserPort settings (Increase maximum port connection): Found
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters the registry subkey and creates a key namedNew REG_DWORD value for MaxUserPort Set this value to the decimal lowest  32768 The value wait time will be  30  seconds. Restart the Windows system. Default value for this entry: 5000 (decimal)
Close Registry Editor,  restart the Windows system.
(Hkey_local_machine\system\currentcontrolset\services\tcpip\parameters\tcptimedwaitdelay
If this item is not tcptimedwaitdelay in the registry, increase this item and set it to double-byte (DWORD) type numeric value set to 30 ~ 60 )

Another reason is
About can ' t connect to mysql server on  ' localhost   (10048)
This bug appears in a loop, Once every run, the mysql database is connected once. The
does not appear in my own windowx xp , but it appears in  windows 2003 server, x32. .
because Win32po will have a delay every time  release rtand close p ort . To cause this bug. The
can look at the following  forum discussion:
http://bugs.mysql.com/bug.php?id=6580
and Microsoft's solution for this bug ... Very troublesome ... How does
http://support.microsoft.com/kb/q196271/
work?
As long as you remove  mysql_close () .  only at the end of  program  put a  mysql_close ()   can solve this problem.

Resolve 2003 Can ' t connect to MySQL server on ' localhost ' (10048)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.