Php running prompt: Can ''tconnecttomysqlserveron' localhost

Source: Internet
Author: User
Sometimes, when we run php, the page prompts CantconnecttoMySQLserveronlocalhost, so we need to refer to the following method to solve the problem.

Sometimes, when we run php, the page prompts Can't connect to MySQL server on 'localhost', so we need to refer to the following method to solve the problem.

Error No:2003

Problem Analysis:

Unable to connect to the MySQL server, possible situation:

1. the MySQL service is not started. It is generally caused by the failure of MySQL to start in case of exceptions, such as no available disk space or incorrect basedir path setting of MySQL in my. ini;

2. the MySQL server cannot be connected due to insufficient resources.

Solution:

1. If you are a VM user (purchased space), contact the Space Provider to check whether MySQL is started normally and confirm the MySQL configuration information (whether it is localhost );

2. If you are an independent host user (with host management permissions), perform the following steps:

1) check whether the MySQL service is started.

For a Windows host, right-click my computer, click manage, and find the MySQL service in the services and applications to check whether it is in the enabled status.

On a Linux host, run service mysql start on the console to start the MySQL service.

2) check whether there is any available space in the disk space and try to keep enough disk space available.

3) check whether the parameter settings of basedir (MySQL installation address) and datadir (data directory storage address) in my. ini are correct, and then restart the MySQL service.

4) if the server is occasionally displayed normally after refresh and the server is a Windows system, reducing the TcpTimedWaitDelay time in Windows can solve this problem, the default value is 240 (this value is also used if not set) you need to set HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ Tcpip \ Parameters \ TcpTimedWaitDelay at the following position. If the TcpTimedWaitDelay project is not found, add this project, and set it to the double byte (DWORD) type value to 30 ~ Between 60

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.