0

Hai friends,
I had a main web site and a number of 15 ( also increasing ) child websites. I had a master database in my main website. Now I need to connect main database from the child websites. I had a code to connect the database from main website that is...

mysql_connect("localhost", "user_name","password") or die(mysql_error());
mysql_select_db("database_name") or die(mysql_error());

I tried this code on child website. But access denied error showing. I already set all privileges to the above user . I tried this code

mysql_connect("mydomain.com", "user_name","password") or die(mysql_error());
mysql_select_db("database_name") or die(mysql_error());

I also tried www.mydomain.com, http://mydomain.com, ip address of my domain insted of "localhost" . But cant connect...


Please give me a help in the above problem.
Thanks in advance
Rajeesh

2
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by rajeesh_rsn
0

Do you use shared web hosting?
Most shared hosting limit mysql connection from localhost only due to security reason. You cant connect to mysql on a shared hosting from different host.

Ask your hosting provider whether they provide "Remote MySQL", or move all of your website to one single server.

0

Thanks for your kind advice.
I solved the problem using Remote MySQL, as you said i just added my host name in to remote mysql like XXX.XX.XXX.%.

If you don't mind please let me know for what "%" is using. Is there is any security issue if I enable remote MySQL

Once again thanks for your support
Rajeesh

Do you use shared web hosting?
Most shared hosting limit mysql connection from localhost only due to security reason. You cant connect to mysql on a shared hosting from different host.

Ask your hosting provider whether they provide "Remote MySQL", or move all of your website to one single server.

0

% mean "from any host"

user1@localhost mean "user1 who came from localhost only"
user1@% mean "user1 who came from anywhere"

disabling remote mysql is the safest option, since you can sure that only script resides on your own server are allowed to access your database.

By enabling remote mysql with wildcard (the %), your database can be accessed (and of course, brute forced) from anywhere.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.