2012-01-22 15 views
3

私はこの質問をここ数回、インターネットで数回見つけましたが、何も答えられませんでした。リモートmysqlへのローカルサーバー接続

私はローカルのApache + PHPサーバーを持っていて、リモートのmysqlデータベースに接続しようとしています。しかし、このスクリプトは私にエラーを返し、エラーログに私が参照してください。

PHP Warning: mysql_connect(): Premature end of data (mysqlnd_wireprotocol.c:553) in D:\\_SERVER\\_WWW\\project\\api\\classes\\database.php on line 13 
PHP Warning: mysql_connect(): OK packet 1 bytes shorter than expected in D:\\_SERVER\\_WWW\\project\\api\\classes\\database.php on line 13 
PHP Warning: mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file in D:\\_SERVER\\_WWW\\project\\api\\classes\\database.php on line 13 

スクリプトを接続(サーバに接続している部分だけ)のために:

function db_connect(){ 
    // Connect to the database server 
    $connection = mysql_connect("server.com:3306","username","password",true); 
    if (!$connection){ 
     echo "Could not connect to the Database server, please check your settings"; 
     die; 
    } 
... 
} 

PASSWORDを設定するとトリックが私のために動作しませんでした、誰か助けてくれますか?

は、リモートのサーバーのIPアドレスからの着信MySQLの接続を許可する必要があなたに

+0

リモート接続が許可されていない場合は、ではないでしょうサーバーに直接接続することができます。 – Nazariy

+0

?私はリモート接続の設定がうまくいかなければならないと思うが、ここで何が問題なのかわからない – Tom

+0

固定ストリングをエコーするのではなく、エラーの実際の理由をエコーアウトする "if(!$ connection){die(mysql_error());}' –

答えて

0

ありがとうございます。これは、リモートサーバからMySQL設定ファイル内に追加することができます。

設定ファイルの編集方法の詳細については、こちらの説明をご覧ください。 http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html

+0

ありがとうございますが、まだ同じエラーが出るのを助けてくれませんでした。 – Tom

+0

可能な解決策を探してください:http://stackoverflow.com/q/10420831/1031312 – Ozzy

0

ファイアウォールは、サーバーにポートフォワードする必要がある:それぞれのシステム上のポート、 静的またはDHCPアドレス予約を必要とするMySQLサーバマシンの

関連する問題