Php remote connection server error.

Source: Internet
Author: User
Php remote connection server error.
$ Host = 'remote server IP'; $ root = 'username'; $ pwd = 'password'; $ con = @ mysql_connect ($ host, $ root, $ pwd ); mysql_query ("set names 'utf8'"); @ mysql_select_db ("XS_CQC", $ con) or die (mysql_error ());

It is normal for me to connect to the local database, but this error is reported if I connect remotely.

Access denied for user 'ODBC'@'localhost' (using password: NO)

What does this mean?


Reply to discussion (solution)

Now the code is on one server, and the database is on another server.
Is there a problem with my code?

Remote connection to MySQL requires authorization from the other party

The account connecting to the remote database must have the permission to connect to the remote database.
Run
> Grant all privileges on database name. * TO 'username '@' % 'identified by 'password' with grant option;
> Flush privileges;

In this way, you can

    $host = 'localhost';    $root = 'ODBC';    $pwd = '';        $con = @mysql_connect($host,$root,$pwd);     mysql_query("set names 'utf8'");    @mysql_select_db("XS_CQC", $con) or die(mysql_error());


Dare to ask if your source code is written in this way. isn't it even a remote server? your ip address and user password seem to have not been changed.

No link permission,
What access permissions are required for the target mysql database.
Set user and host in phpmyadmin

    $host = 'localhost';    $root = 'ODBC';    $pwd = '';        $con = @mysql_connect($host,$root,$pwd);     mysql_query("set names 'utf8'");    @mysql_select_db("XS_CQC", $con) or die(mysql_error());


Dare to ask if your source code is written in this way. isn't it even a remote server? your ip address and user password seem to have not been changed.



The source code is the IP address of the remote server written above, but it is not convenient to disclose the IP address and user name of the server. Chinese.

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.