You are here: Re: Connection to a database on an external server « PHP Programming Language « IT news, forums, messages
Re: Connection to a database on an external server

Posted by Michael Fesser on 10/13/07 12:42

..oO(Tschuß)

>I have my own database on a server and the same database on local.
>I want to copy all my database from the main server to my local host
>(I execute this code from my PC and not my main server)
>
>$id_link_ref = mysql_connect('localhost','database_name','password');
>$id_link_local = mysql_connect('localhost','root','password');
>
>it doesn't work :(

"Doesn't work" is not really an error description. But your code above
contains several obvious problems:

* The parameters in the first call are wrong. The first parameter is the
server name or address, which should obviously not be 'localhost' if you
want to connect to an external server.

* Running your local database as 'root' is a really bad idea. You should
consider to create a normal user account with restricted permissions for
the daily work. Use 'root' only for maintenance purposes.

* After all connecting to an external database server is often not
possible at all for security reasons. Many hosts allow such access only
from within their own network, not from the outside.

So the better solution is to use the MySQL command line tools to dump
and import the database. Run 'mysqldump' on the server, download the
created dump file and use 'mysql' on your own machine to import it.

If you don't have shell access to the remote machine, see if there's
something like phpMyAdmin available to create the dump. Another possible
way would be to call 'mysqldump' from withing a PHP script and then
download the file.

Micha

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация