473,320 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Connection to a database on an external server

Hi,

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','passwor d');
$id_link_local = mysql_connect('localhost','root','password');

it doesn't work :(
Why ? What is the problem ?

Oct 13 '07 #1
2 2235
..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','passwor d');
$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
Oct 13 '07 #2
>I have my own database on a server and the same database on local.

Does that mean *TWO DIFFERENT MACHINES*?

Many hosts do not permit database access from arbitrary hosts
for "security reasons".
>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','passwor d');
$id_link_local = mysql_connect('localhost','root','password');
If you are trying to open a connection to two different machines,
shouldn't one of the hostnames NOT be 'localhost'? Also, the second
argument to mysql_connect is a username, NOT a database name,
although they might coincidentally be the same.
>it doesn't work :(
How do you know it failed?
>Why ? What is the problem ?
What was the error message?

Oct 13 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Gloria | last post by:
Hi, I've been having problems with my CGI script, it overloads the server. I think it's because the database connection fails because the following error is logged whenever the server overloads. ...
3
by: Chad Richardson | last post by:
Yes, it should be easy.... I have a single box hosing IIS and SQL Server 2000. In my ASP script I've tried using the following connection strings to attempt to connect to no avail: ...
2
by: Ian Davies | last post by:
Hello Stefan or anyone else who can help Some time ago you suggested a solution to my original post about connecting to data on a remote server from a VB application where my host doesnt allow a...
0
by: Igor | last post by:
An error "ODBC connection to failed" is raised when I am trying to get data from a table in Microsoft Access (97, or 2000) which is actually a linked table to another table in SQL Server 7 . The...
12
by: Charlie | last post by:
Hi: My host will not allow me use a trusted connection or make registry setting, so I'm stuck trying find a way to hide connection string which will be stored in web.config file. If I encrypt...
2
by: Mahesh Devjibhai Dhola | last post by:
Hi, I want to develop p2p (peer-to-peer) communication connection for chat in ..Net (Lang: c# - preferable) NOTE: if two LAN are behind their own router then also it should work as yahoo, msn...
1
by: Michael | last post by:
Hello, I am trying to develop a database solution for an organisation in Indonesia. This organization has a number of offices and users throughout the country. They all need to maintain their...
9
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I have a question about storing the connection strings to the database in a config file or database. My manager wants me to store all the connection strings in a database, but I...
2
by: aidanhaylock | last post by:
Morning, This one is really driving me insane. I am developing a site for a client who doesn't particularly want to move their hosting away from their current provider. The current host are...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.