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.