2010-08-17 21 views
5

Bu yüzden bir arkadaşım ve ben, her ikisi de xampp'i ubuntu'da kullanıyoruz, eğer bu yardımcı oluyorsa, birbirlerinin web sitesi arasında bağlantı kurabilirsek, her ikisi de bağlanacak aynı php dosyasını yarattık, bu yüzden de IP'yi kullanıyoruz biz sadece böyle IP kullanırsanızXAMPP MySql Veritabanını Başka Bir Bilgisayardan Kabul Etme

<?php 
$link = mysql_connect('10.100.161.37','root',''); 
if (!$link) { 
    die('Could not connect: ' . mysql_error()); 
} 
//echo 'Connected successfully'; 

$db_selected = mysql_select_db('Prueba', $link); 
if (!$db_selected) { 
    die ('Can\'t use Prueba : ' . mysql_error()); 
} 

// This could be supplied by a user, for example 
$firstname = 'fred'; 
$lastname = 'fox'; 

// Formulate Query 
// This is the best way to perform an SQL query 
// For more examples, see mysql_real_escape_string() 
$query = sprintf("SELECT * FROM Agencia"); 

// Perform Query 
$result = mysql_query($query); 

// Check result 
// This shows the actual query sent to MySQL, and the error. Useful for debugging. 
if (!$result) { 
    $message = 'Invalid query: ' . mysql_error() . "\n"; 
    $message .= 'Whole query: ' . $query; 
    die($message); 
} 

// Use result 
// Attempting to print $result won't allow access to information in the resource 
// One of the mysql result functions must be used 
// See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc. 
while ($row = mysql_fetch_assoc($result)) { 
    echo $row['ID'] . " "; 
    echo $row['Nombre'] . "\n\r"; 
} 

// Free the resources associated with the result set 
// This is done automatically at the end of the script 
mysql_free_result($result); 
mysql_close($link); 
?> 

, biz birbirlerinin xampp girebilirsiniz: ötekinin, ama sonra bir hataya

Warning: mysql_connect() [function.mysql-connect]: Host 'coke-laptop.local' is not allowed to connect to this MySQL server in /opt/lampp/htdocs/connection.php on line 2 
Could not connect: Host 'coke-laptop.local' is not allowed to connect to this MySQL server 

Biz connection.php kayıtlı bu kodu var diyor normal karşılama sayfası.

+0

veritabanına 'kok-laptop.local' erişim verdik

# skip-networking 

sonra yeniden MySQL sunucusu: Bu gibi görünüyor böylece skip-networking o açıklama? Yani Bu ana bilgisayar için veritabanına erişebilen bir kullanıcı var mı? – Stephen

cevap

9

kontrol edin. diyen bir çizgi varsa

bind-address=192.168.1.100 

my.cnf dosyasını açın (muhtemelen xampp/etc/içinde bulunan), [mysqld] bölümüne gidin ve (örneğin yerine kullanarak kendi ip adresi) aşağıdakileri ekleyin

1

MySQL veritabanınız, sağladığınız kimlik bilgileriyle uzaktan bağlanmanıza izin vermiyor gibi görünüyor. Bağlanmak için uzak bir kullanıcı yapılandırmanız gerekecektir. MySQL Grants'u incelemeyi deneyin. Örnek için

: Eğer MySQL sunucusuna uzaktan erişim sağladı

GRANT SELECT, INSERT ON database.* TO 'someuser'@'somehost'; 
İlgili konular