开发者

problem connecting to remote mysql database using php

开发者 https://www.devze.com 2023-03-14 22:43 出处:网络
If I open up a cmd shell and run >mysql --host=12.34.56.78 --port=1234 --user=myuser --password=mypassword mydb

If I open up a cmd shell and run

>mysql --host=12.34.56.78 --port=1234 --user=myuser --password=mypassword mydb

I can successfully connect to the remote mysql database.

But if I create a php page on my localhost containing

<?php
$hostname = "12.34.56.78:1234";
$username = "myuser";
$password = "mypassword";
$dbname   = "mydb";
$connect = mysql_connect($hostname,$username,$password) or die ("Error: could not connect to database");
?>

I get the following error:

Error: could not con开发者_Python百科nect to database

Can anyone explain what might be causing the problem here?

mysql_error() => mysqlnd cannot connect to MySQL 4.1+ using old authentication


Auth problems are a known issue with PHP 5.3 and older versions of MySQL. Check this:

http://www.bitshop.com/Blogs/tabid/95/EntryId/67/PHP-mysqlnd-cannot-connect-to-MySQL-4-1-using-old-authentication.aspx


maybe in your php.ini parameter sql.safe_mode is "1"?

sql.safe_mode boolean 

If turned on, database connect functions that specify default values will use those values in place of supplied arguments. For default values see connect function documentation for the relevant database.

0

精彩评论

暂无评论...
验证码 换一张
取 消