简体   繁体   English

远程数据库连接字符串

[英]Remote Database Connection String

Hi I am new to PHP and MySQL I have created an application on LAMP and uploaded on net4.com a website hosting company. 嗨,我是PHP和MySQL的新手,我已经在LAMP上创建了一个应用程序,并在net4.com上上传了一个网站托管公司。 They are using phpMyAdmin in order to connect to the database which I am able to successfully the problem arises when I try to connect to database using php and query the database. 他们使用phpMyAdmin来连接到数据库,当我尝试使用php连接到数据库并查询数据库时,便能够成功地出现问题。 I am using the mysql_connect() function which I have been using successfully on my local machine to connect to the remote database ie 我正在使用已经在本地计算机上成功使用的mysql_connect()函数来连接到远程数据库,即

$link = mysql_connect("118.67.248.12",  "username", "password");

where "118.67.248.12" is the ip address of the server where my database resides, it throws the following error: 其中“ 118.67.248.12”是数据库所在的服务器的IP地址,它将引发以下错误:

"1045Access denied for user 'Technosaar'@'118.67.248.190' (using password: YES)" “ 1045用户'Technosaar'@'118.67.248.190'的访问被拒绝(使用密码:是)”

and if I use localhost" in place of "118.67.248.12" it throws the following error: 如果我使用localhost“代替” 118.67.248.12“,则会引发以下错误:

"2002No connection could be made because the target machine actively refused it." “ 2002无法建立连接,因为目标机器主动拒绝了它。”

I am already bugged up calling "net4" support guyz but the problem still persist Somebody please help me out, May Day May Day! 我已经打了个电话,打电话给“ net4”支持人员,但是问题仍然存在,有人可以帮我解决,五月天五月天!

The latter (localhost) isn't working I assume because the web server and database server aren't running on the same machine. 我认为后者(localhost)无法正常工作,因为Web服务器和数据库服务器不在同一台计算机上运行。

Are you certain that the password is set correctly on the server? 您确定服务器上的密码设置正确吗? This looks like an authentication error to me. 对我来说,这似乎是身份验证错误。

"1045 Access denied for user 'Technosaar'@'118.67.248.190' (using password: YES)" hints at missing access rights for the user Technosaar from your web server. “用户'Technosaar'@'118.67.248.190'的1045访问被拒绝(使用密码:是)”提示您Web服务器中用户Technosaar访问权限丢失。 Login to phpmyadmin and enter the command 登录到phpmyadmin并输入命令

show grants;

or 要么

show grants for '<myuser'@'<host>';

There should be a line like 应该有这样一条线

grant <privilege> on <mydatabase> to '<myuser>'@'<host>' 将<mydatabase>上的<privilege>授予'<myuser>'@@'<host>'

There you will see what access rights are configured for your user. 在那里,您将看到为用户配置了哪些访问权限。 If your webserver isn't listed, you must 如果您的网络服务器未列出,则必须

grant all privileges on <mydatabase>.* to '<myuser>'@'<host>';

or whatever privileges you need for your database. 或数据库所需的任何特权。

Insert the appropriate database name, user name and webserver host, of course. 当然,插入适当的数据库名称,用户名和Web服务器主机。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM