0

For

$conn = mysql_connect("192.168.0.235", "root", "") or
    die("Could not connect: " . mysql_error());

mysql_select_db("crossdomaintest");

$result = mysql_query("SELECT * FROM testing");

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
    echo $row[1].$row[2].$row[3]."<br/>"; 
}

mysql_free_result($result);

I am getting

Warning: mysql_connect() [function.mysql-connect]: Host '192.168.0.167' is not allowed to connect to this MySQL server in /var/www/test.php on line 3 Could not connect: Host '192.168.0.167' is not allowed to connect to this MySQL server

And my IP is 192.168.0.168 and I am using LAMP on Ubuntu 10.10 and 192.168.0.235 is using XAMPP on windows 7 i can access all sites on ...235 but not access database from my local-server.

Any ideas?

3
  • check to see if you can access the mysql port on windows. Commented Mar 20, 2011 at 8:42
  • Currently going offline now please any effort will be appreciated. Commented Mar 20, 2011 at 8:46
  • Use a good database managing program in linux and see if you can connect to windows database using that. Col. Shrapnel is also right, the appropriate privileges on your friend's computer must have been set for the ip of your computer so you can connect to that. (No, i don't know db programs for linux and have no idea where in the windows you should set the privileges.) Commented Mar 20, 2011 at 9:02

2 Answers 2

3

it's not about "how to connect". connecting would be all the same.
it's about how to setup remote server to allow connections from your IP.
do you have root privileges on the db server on 192.168.0.235? if so, you have to run appropriate GRANT PRIVILEGES query on it.
If not - ask a db admin to do that

I'd also advise not to use root user to access remote database. Better create another user and give him appropriate privileges

Sign up to request clarification or add additional context in comments.

7 Comments

well, i know the root username and password i am connecting as simply a webrequest. but honestly i don't know a lot of stuff for neetworking
@experimentX, you are not connecting as a web request, MySQL doesn't work that way. You are connecting with MySQL's protocol over TCP/IP. Also, this has nothing to do with networking (other than that you are using one). This has to do with the proper permissions on your MySQL installation. Col. Shrapnel is correct.
GRANT ALL ON * TO 'root'@'%' IDENTIFIED BY 'somepassword'; should do it. Be careful though, you're opening yourself up to trouble. MySQL's protocol is fairly plain-text, and certainly isn't encrypted, unless you connect over SSL, which you aren't doing. Remote root access is generally a bad idea. Instead, you should set up a separate user account that has access only to what you need.
@Brad @Col.Shrapnel thanks for info, but i got one question, I can access mysql from terminal, and as well from localhost i.e. apache, and i use username and password to connect to it, am i still connecting through TCP/IP from my localserver to mysqldb?
@experimentX ... What does that have to do with your question. If you have a separate question for working "offline", please explain what you need in a new question. Usually if you need a couple systems to function while disconnected and then sync up, you need local servers on each side, and replication. You shouldn't mess with replication at this point. Get the basics down first.
|
0

Did you change to root user access the host "%"?

Sorry for my english i'm french.

  • Cosmik.

2 Comments

mean?? i am loggin as a root user there, it's my friend computer
@experimentX, each user in MySQL is given a host. Usually, root is only allowed to login from localhost. If you don't grant permissions to the wild-card host (%, meaning any-host), then you won't be able to login.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.