Php connection to mysql error message: unable to connect due to the active rejection of the target computer

Source: Internet
Author: User
Php connection to mysql error prompt: because the target computer is actively rejected, it is no problem to be unable to connect to mysql using a command prompt, including query insertion and update.
Php. ini configuration:; extension = php_mysql.dll
; Extension = php_mysqli.dll
The semicolon above is removed.
The error message is as follows:
Warning: mysql_connect () [function. mysql-connect]: [2002] Unable to connect due to the active rejection of the target computer. (Trying to connect via tcp: // localhost: 3306) in F: \ Apache \ htdocs \ ch13 \ 13-1.php on line 6
Warning: mysql_connect () [function. mysql-connect]: unable to connect because the target computer is actively rejected. In F: \ Apache \ htdocs \ ch13 \ 13-1.php on line 6
Database Connection failed:
Unable to connect because the target computer is actively rejected.

The php code is as follows:
 '. Mysql_error ();} echo' database connection successful! ';?>


Reply to discussion (solution)

Thank you for your support.

Haha .. You have no permission to access the database.

Then the username and password can be determined as follows for $ user_name = 'root ';
$ Password = 'admin ';

User permission issues, you can see if your command prompt operation does not have a user database.

It is estimated that the configuration of the php. ini file is incorrect.

This indicates that after you connect to the target machine, its system will automatically be regarded as an attack object,

You shut down his firewall.

It is estimated that the firewall has blocked












Bytes ---------------------------------------------------------------------------------------------
Http://www.jiemengwu.com/dream house http://www.phpzy.com/php/ green php resources http://www.shopfw.com online shop service

There is no problem with using a command prompt to operate mysql, including querying, inserting, and updating data.
Php. ini configuration:; extension = php_mysql.dll
; Extension = php_mysqli.dll
The semicolon above is removed.
The error message is as follows:
Warning: mysql_connect () [function. mysql-connect]: [2002] Unable to connect due to the active rejection of the target computer ......


Check whether the user name and password are correct, and then check whether the firewall disables the default port of MYSQL.

I tried to shut down the firewall. in my personal experience, I thought it was a Firewall problem. it should be because Port 3306 was rejected.

User permission issues, you can see if your command prompt operation does not have a user database.
There is no user database. how can I set it?

None of my USER databases can be connected normally.

Show database: displays several databases;
There is no user database, but there is a user table under the mysql database.

After the firewall is disabled, an error still persists. I installed 360 security guard and 360 anti-virus service. can I uninstall it and try again?

After the firewall is disabled, an error still persists. I installed 360 security guard and 360 anti-virus service. can I uninstall it and try again?

Is it PHP5.3? If yes, it is estimated that your database connection server name is set to localhost and changed to 127.0.0.1,

Try it, because PHP5.3 and later do not support direct connection with localhost

There is also such a problem. I have never encountered it. The information prompted by it should be a firewall problem. since it cannot be turned off, I really don't know, telnet 127.0.0.1 3306 to see if you can log on. It may be about the database version.

If you encounter the same problem, please give detailed instructions. thank you!

I have encountered the same problem. I just need to add the port number in the program.
$ Conn = mysql_connect ("127.0.0.1: 3307", "root", "root") or die (mysql_error ());
If (! $ Conn) echo "Failed! ";
Else echo "Successful! ";
Print_r ($ conn );
Mysql_close ();
?>

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.