警告:mysqli_connect():(HY000/2002):试图以其访问权限禁止的方式访问套接字
已经两天了,我仍在尝试解决此问题
For two days yet I trying to resolve this problem
警告:mysqli_connect():(HY000/2002):试图以其访问权限禁止的方式访问套接字.
Warning: mysqli_connect(): (HY000/2002): An attempt was made to access a socket in a way forbidden by its access permissions.
我的托管服务器是Azure,他的界面非常糟糕.编程语言是PHP,我与域在同一个资源组中有数据库,帐户数据正确.我做错了什么?
My hosting is Azure and he has very bad interface. Programming language is PHP, I have database in same resource group with domain, account data is correct. what I do incorrect?
有问题的行
mysqli_connect($SERVER, $USER, $PASSWORD, $DATABASE);
要在CLearDB上使用MySQL在Web应用程序中获取连接字符串:
To get your connection string in a Web App with MySQL on CLearDB:
- 在Azure门户中选择您的服务
- 点击设置
- 选择应用程序设置"并向下滚动到连接字符串",然后单击显示连接字符串值"
-
复制表格的中间列,您将得到类似的内容:
- select your service in Azure Portal
- click Settings
- select Application Settings and scroll down to Connection String and click in "Show connection string values"
copy the middle column of the table you will get something like:
数据库= YOUR_DATABASE_NAME;数据源= YOUR_HOSTNAME;用户ID = YOUR_USERNAME;密码= YOUR_PASSWORD
Database=YOUR_DATABASE_NAME;Data Source=YOUR_HOSTNAME;User Id=YOUR_USERNAME;Password=YOUR_PASSWORD
就是这样,复制并替换您的代码!
That's it, copy and replace in your code!
Protip :您可以ping YOUR_HOSTNAME并使用IP代替HOSTNAME来提高速度;)
Protip: you can ping YOUR_HOSTNAME and use the IP instead the HOSTNAME to improve speed ;)