Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial php 连接mysql出错,由于目标计算机积极拒绝,无法连接

php 连接mysql出错,由于目标计算机积极拒绝,无法连接

Jun 23, 2016 pm 01:28 PM

错误代码:

PHP Warning:  mysql_connect() [function.mysql-connect]:  in E:\网站\weixinpublic\connectdb.php on line 6
PHP Warning:  mysql_query() [function.mysql-query]: [2002] 由于目标计算机积极拒绝,无法连接。
 (trying to connect via tcp://localhost:3306) in E:\网站\weixinpublic\connectdb.php on line 7
PHP Warning:  mysql_query() [function.mysql-query]: 由于目标计算机积极拒绝,无法连接。
 in E:\网站\weixinpublic\connectdb.php on line 7
PHP Warning:  mysql_query() [function.mysql-query]: A link to the server could not be established in E:\网站\weixinpublic\connectdb.php on line 7

忘记是由于什么操作导致的这个问题,现在用网页连不上mysql。mysql都重装了还是连不上。

已经排除防火墙问题,防火墙关掉了。
host文件也改成    127.0.0.1  localhost 做了解析。
用的root 来连接的。不会设置my.ini 无法查看warning的日志。

本地用cmd   连接没问题,tenlnet  出来一个mysql_native_password 应该是也连上了。。

请教该如何解决??


回复讨论(解决方案)

查看了应用程序日志  发现有这么一行  :Server hostname (bind-address): '0.0.0.0'; port: 3306

这个绑定会有影响吗?0.0.0.0  应该也是本地主机的ip吧

MySQL 服务没有启动

MySQL 服务没有启动



已经启动了,用cmd命令能访问数据库

MySQL 的版本是多少?

MySQL 的版本是多少?



是5.5的版本,用cmd和work...那个软件都能连上。之前用一直好的。我对进行了一次什么操作后就不能访问了,具体什么操作忘记了。

发现一个问题  就是即使我用的服务器的ip地址来连服务器上的mysql    
如:$connection=mysql_connect('59.188.180.234:3306',$db_username,$db_password);


php页面仍然提示的是 

PHP Warning:  mysql_connect() [function.mysql-connect]:  in E:\网站\weixinpublic\connectdb.php on line 6
PHP Warning:  mysql_query() [function.mysql-query]: [2002] 由于目标计算机积极拒绝,无法连接。
 (trying to connect via tcp://localhost:3306) in E:\网站\weixinpublic\connectdb.php on line 7
PHP Warning:  mysql_query() [function.mysql-query]: 由于目标计算机积极拒绝,无法连接。
 in E:\网站\weixinpublic\connectdb.php on line 7
PHP Warning:  mysql_query() [function.mysql-query]: A link to the server could not be established in E:\网站\weixinpublic\connectdb.php on line 7


求解高手,来帮助一下,我折腾不动了

那你的 MySQL 是单独安装的吗?

那你的 MySQL 是单独安装的吗?


是单独安装的,我估计是我电脑的php设置问题。该用的办法都用了,远程的mysql没道理连不上的啊,以前都可以连的。而且如果用了域名来连远程mysql,会提示找不到主机。但是ping 域名又ping的通。。。

你是远程连接?
那么授权了没有

你是远程连接?
那么授权了没有



不是远程连接,是本地连接,因为本地连不上,所以我试试看能不能连远程mysql,然后发现远程也连不上(不排除是服务器拒绝),但是本地连不上,到底是什么原因,用cmd都可以连。

那  远程的mysql没道理连不上的啊 是什么意思?
远程连接就必须授权,这是规则

你执行 phpinfo() 把 PATH 想的值贴出了看看

那  远程的mysql没道理连不上的啊 是什么意思?
远程连接就必须授权,这是规则

你执行 phpinfo() 把 PATH 想的值贴出了看看


现在在公司,电脑在家里。path项指的是php.ini 配置的路径吗?

PATH 是操作系统的环境变量,用于通知操作系统到哪里去找到要执行的软件

PATH 是操作系统的环境变量,用于通知操作系统到哪里去找到要执行的软件



额,那这个也是看php可执行文件的路径吧,看了后能怎么弄呢?

不是,要看 MySQL 的路径是否也在其中
如果在的话,应删去的

要看你mysql配置文件绑定的IP地址是什么 尝试使用 localhost  和  127.0.0.1 看看能否连上

要看你mysql配置文件绑定的IP地址是什么 尝试使用 localhost  和  127.0.0.1 看看能否连上


两个地址都用过,mysql 绑定ip的设置  bind_address 吧,我在my.ini 中没有看到这个,应该是没设置吧

还有可能是什么原因呢,用cmd和mysql_workbench  都能连。。

如果是本地连接,那你把ip换成localhost或者127.0.0.1
如果是远程的ip,需要开启远程的权限。

Linux的话检查端口是否对外开放,可能防火墙限制了。可以用telnet ip 段口号测试端口是否通

最好是phpinfo()下,贴出来看下,感觉是你php改了什么配置了吧。

如果是本地连接,那你把ip换成localhost或者127.0.0.1
如果是远程的ip,需要开启远程的权限。



换过了,还是连接不了。。
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Check network connection: lol cannot connect to the server Check network connection: lol cannot connect to the server Feb 19, 2024 pm 12:10 PM

LOL cannot connect to the server, please check the network. In recent years, online games have become a daily entertainment activity for many people. Among them, League of Legends (LOL) is a very popular multiplayer online game, attracting the participation and interest of hundreds of millions of players. However, sometimes when we play LOL, we will encounter the error message "Unable to connect to the server, please check the network", which undoubtedly brings some trouble to players. Next, we will discuss the causes and solutions of this error. First of all, the problem that LOL cannot connect to the server may be

Why can't Bluetooth connect to Windows 10 computer? Why can't Bluetooth connect to Windows 10 computer? Jul 16, 2023 am 08:03 AM

Through Bluetooth devices, we can transfer files without a network connection, or connect Bluetooth headsets to listen to music, etc. However, some netizens recently said that their win10 computer’s Bluetooth cannot connect. What’s going on? The editor below will teach you how to solve the problem that the win10 Bluetooth device cannot be connected. This situation may be caused by a driver problem. The following editor will show you the specific solution: 1. Click the Cortana search box in the lower left corner of win10, enter "Device Manager", click and open "Device Manager". 2. In the device manager, click "Bluetooth". 3. Select "QualcommAtherosBluetooth" in the expanded list. 4. Right-click and select "Update Driver". 5.

Network printer cannot connect Network printer cannot connect Jan 24, 2024 pm 01:53 PM

Solutions for network printers that cannot connect: 1. Network connection problem; 2. Printer setting problem; 3. Driver problem; 4. System file damage; 5. Firewall or anti-virus software settings; 6. Server service not turned on; 7. Sharing The service is not turned on; 8. The computer browser service is not turned on. Detailed introduction: 1. Network connection problem. First, make sure the network connection is normal. You can test the network connection through the ping command. If the computer cannot ping the network printer, there may be a problem with the network connection. You can try restarting the router or switch, etc.

Win10 is recognizing the solution for being unable to connect to the internet Win10 is recognizing the solution for being unable to connect to the internet Jul 11, 2023 pm 06:21 PM

When you use a win10 computer, have you ever encountered a situation where you are unable to connect to the internet? If you don't know how to solve this problem, let's take a look at this article. 1. Use the Win+I key combination to bring up the settings window, click to select Network and Internet. 2. Click Ethernet on the left side of the Network and INTERNET window, and then click Change Adapter Options in the right window. 3. In the Network Connection window, right-click Ethernet (desktop, please treat mobile devices as appropriate), and click Disable in the menu. 4. After it is displayed as disabled, right-click the Ethernet mouse and execute the enable command. Once Ethernet is enabled, the problem should be resolved. Here is an introduction to Win10 network failure prompt identification without

What should I do if Win7 cannot connect to the remote desktop? Tips for solving the problem of Win7 unable to connect to the remote desktop What should I do if Win7 cannot connect to the remote desktop? Tips for solving the problem of Win7 unable to connect to the remote desktop Jun 02, 2024 pm 07:34 PM

Recently, many users using Win7 system have found that they cannot connect to the remote desktop. This is probably caused by registry settings. So how to solve it? Let’s take a look below! 1. First, press the "Win+R" keys to open the run window, and enter the "regedit" command to open the registry editor. 2. Then, in the opened registry interface, click to expand "Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\TerminalServerClient". 3. Then, right-click on the blank space and select "

How to solve 0x00000006 Unable to connect to printer How to solve 0x00000006 Unable to connect to printer Nov 07, 2023 pm 12:14 PM

Solutions include checking the connection, checking the driver, checking the network connection, checking the printer status, checking the print queue, restarting the device, etc. Detailed introduction: 1. Check the connection: Make sure the printer is turned on and connected correctly to the computer. If using USB connection, please make sure the USB cable is firmly connected and try changing the USB port; 2. Check the driver: Make sure the printer driver is installed correctly. Try to reinstall or update the printer driver. You can download the latest driver from the printer manufacturer's official website; 3. Check the network connection, etc.

What does it mean when unable to connect to steam network? What does it mean when unable to connect to steam network? Sep 13, 2023 pm 01:24 PM

The inability to connect to the Steam network refers to the situation where the user cannot connect to the Steam server normally when using the Steam platform. The reasons are as follows: 1. Network connection problem, you should check whether the network connection is normal, restart the router, turn off the firewall or add Steam to the exception list of the firewall; 2. Steam server problem, the user can only wait for the Steam server to return to normal; 3. Computer Or problems with the Steam client, update the operating system and drivers, clear the cache of the Steam client, etc.

What to do if there is no local connection in win7 system What to do if there is no local connection in win7 system Jun 29, 2023 pm 01:46 PM

What should I do if there is no local connection in win7 system? Win7 system cannot make local connection. How to solve the problem and share the tutorial. After reinstalling win7 system or just installing a new system on the computer, the user finds that his computer cannot connect to the network. Many users will encounter this situation. The reason is that the computer does not have the corresponding driver, and they need to update it or download the driver. Win7 system cannot perform local connection solution operation tutorial sharing 1. If you find that there is no exclamation mark and question mark in front of the network card driver in the device manager, and the driver is normal, then you should consider the error of the network connection management service program. 2. Press and hold the Win key + R key to open the run window. 3. In order

See all articles