PHP connection MySQL error, because the target computer actively refused to connect

Source: Internet
Author: User
Error code:

PHP warning:mysql_connect () [Function.mysql-connect]: in E:\ website \weixinpublic\connectdb.php on line 6
PHP warning:mysql_query () [Function.mysql-query]: [2002] Unable to connect because the target computer was actively rejected.
(Trying to connect via tcp://localhost:3306) in E:\ website \weixinpublic\connectdb.php on line 7
PHP warning:mysql_query () [Function.mysql-query]: Unable to connect because the target computer is actively rejecting.
In E:\ website \weixinpublic\connectdb.php on line 7
PHP warning:mysql_query () [function.mysql-query]: A link to the server could not being established in E:\ site \weixinpublic\con Nectdb.php on line 7

Forgetting is due to what the operation caused by this problem, now with the Web page is not connected to MySQL. MySQL has been re-installed or not connected.

Firewall problem has been ruled out and the firewall is turned off.
The host file is also changed to 127.0.0.1 localhost for parsing.
Used by the root to connect. My.ini cannot be set to view warning logs.

Local with CMD connection no problem, tenlnet out a mysql_native_password should be also connected to the.

Ask how to solve??


Reply to discussion (solution)

Viewed the application log to find a line like this: Server hostname (bind-address): ' 0.0.0.0 '; port:3306

Does this binding have an impact? 0.0.0.0 should also be the IP of the local host

MySQL service does not start

MySQL service does not start



Has been started, with the cmd command to access the database

What is the MySQL version?

What is the MySQL version?



Is the 5.5 version, with cmd and work ... That software can be connected. Used to always be good. I am not able to access the operation once, the specific what operation forgot.

The problem is that even if I use the server's IP address to connect the MySQL on the server
such as: $connection =mysql_connect (' 59.188.180.234:3306 ', $db _username, $db _password);


The PHP page still prompts for the

PHP warning:mysql_connect () [Function.mysql-connect]: in E:\ website \weixinpublic\connectdb.php on line 6
PHP warning:mysql_query () [Function.mysql-query]: [2002] Unable to connect because the target computer was actively rejected.
(Trying to connect via tcp://localhost:3306) in E:\ website \weixinpublic\connectdb.php on line 7
PHP warning:mysql_query () [Function.mysql-query]: Unable to connect because the target computer is actively rejecting.
In E:\ website \weixinpublic\connectdb.php on line 7
PHP warning:mysql_query () [function.mysql-query]: A link to the server could not being established in E:\ site \weixinpublic\con Nectdb.php on line 7


Solve the master, to help, I'm not moving

Is your MySQL installed separately?

Is your MySQL installed separately?


Is installed separately, I estimate is my computer's PHP setup problem. The use of methods are used, remote MySQL does not make sense, ah, can even before. And if you use a domain name to connect to remote MySQL, you will be prompted not to find the host. But ping the domain name and ping ...

Are you a remote connection?
So authorized, No.

Are you a remote connection?
So authorized, No.



is not a remote connection, is a local connection, because it is not connected to the local, so I try to see if I can not even remote MySQL, and then found that the remote is not connected (do not rule out the server refused), but the local not connected, in the end is what reason, with CMD can be connected.

What does it mean that the remote MySQL doesn't make sense?
Remote connection must be authorized, this is the rule

You perform the phpinfo () to put the value of PATH to look

What does it mean that the remote MySQL doesn't make sense?
Remote connection must be authorized, this is the rule

You perform the phpinfo () to put the value of PATH to look


Now in the company, the computer is at home. Does the path entry refer to the php.ini configuration?

PATH is an environment variable for the operating system that informs the operating system where to find the software to execute

PATH is an environment variable for the operating system that informs the operating system where to find the software to execute



Well, then this is the path to the PHP executable file, how can you do it after watching it?

No, see if MySQL's path is in it.
If so, it should be deleted.

To see what the IP address of your MySQL config file binding is trying to use localhost and 127.0.0.1 to see if you can connect

To see what the IP address of your MySQL config file binding is trying to use localhost and 127.0.0.1 to see if you can connect


Two addresses are used, MySQL binding IP settings bind_address, I did not see this in the My.ini, it should be not set it

There may be some reason, with CMD and mysql_workbench can even.

If it's a local connection, you change the IP to localhost or 127.0.0.1.
If it is a remote IP, you need to turn on remote permissions.

Linux to check whether the port is open, the firewall may be limited. You can use the Telnet IP segment number to test whether the port

It is best to phpinfo (), posted to look, feel that you have PHP changed what configuration it.

If it's a local connection, you change the IP to localhost or 127.0.0.1.
If it is a remote IP, you need to turn on remote permissions.



Changed, or can not connect.
  • 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.