How copy a mysql database to another server

Post Reply
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

How copy a mysql database to another server

Post by Rksk » Sun Jun 06, 2010 5:31 pm

howto copy a mysql db to another db on another server with all data using php ?
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: How copy a mysql database to another server

Post by Neo » Mon Jun 07, 2010 12:58 am

There are many options for this.
  1. You can have two connections to both databases and iterate through all tables and copy records.
    Here you can either copy each record using a loop or use something similar as below.
    mysql_query("SELECT * INTO OUTFILE 'temp.sql' FROM my_table", $conn1);
    mysql_query("LOAD DATA INFILE 'temp.sql' INTO TABLE my_table", $conn2);
  2. If you have phpMyAdmin, you can use Export from source and and use Import at destination end.
  3. You can easily use mysqldump to backup your database to a file and then restore it using command "mysql" at destination end.
Last two methods are usually used. However you can use first one if you have an interest to learn php.
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

Re: How copy a mysql database to another server

Post by Rksk » Mon Jun 07, 2010 4:59 pm

i want to backup my db daily with freemysql.net

can you give an eample in php?

thankz
User avatar
Saman
Lieutenant Colonel
Lieutenant Colonel
Posts: 828
Joined: Fri Jul 31, 2009 10:32 pm
Location: Mount Lavinia

Re: How copy a mysql database to another server

Post by Saman » Mon Jun 07, 2010 10:02 pm

See tutorials in that website. All required information are there. If you can't find anything, just ask them. ROBOT.LK can't support on 3rd party products.

Regards...
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

Re: How copy a mysql database to another server

Post by Rksk » Mon Jun 07, 2010 11:51 pm

Thankz.

freemysql.net is only a mysql server.
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: How copy a mysql database to another server

Post by Neo » Tue Jun 08, 2010 12:20 am

Saman wrote:See tutorials in that website. All required information are there. If you can't find anything, just ask them. ROBOT.LK can't support on 3rd party products.

Regards...
I agree. It's all well explained there. Read through http://www.freemysql.net/v2/tutorials/p ... part-1.php.
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

Re: How copy a mysql database to another server

Post by Rksk » Tue Jun 08, 2010 6:09 am

Saman & Neo wrote:ROBOT.LK can't support on 3rd party products.
Both of you have forgot one thing.
if you don't support on 3rd party producs, you will can't help us to use any software , ect.

don't care, a joke only.

thankz.
User avatar
Saman
Lieutenant Colonel
Lieutenant Colonel
Posts: 828
Joined: Fri Jul 31, 2009 10:32 pm
Location: Mount Lavinia

Re: How copy a mysql database to another server

Post by Saman » Tue Jun 08, 2010 10:16 am

Both of you have forgot one thing.
if you don't support on 3rd party producs, you will can't help us to use any software , ect.
3rd Party products means the products that are made using other products. Usually our topics are made for the original products.

For example the product you have added which was build on MySQL. Our topic is MySQL/SQL and Database concepts.

It is usual to have a complete help on site for such products/packages. It is unlikely that you get help for these kind of products from ROBOT.LK as no one is willing to install those on their machines. ;)
Post Reply

Return to “PHP & MySQL”